Question
What am I doing wrong in this code to produce this error in R? > library(mvtnorm) > trueBeta = c(5,8,4,9) > n = 1000; >
What am I doing wrong in this code to produce this error in R?
> library(mvtnorm) > trueBeta = c(5,8,4,9) > n = 1000; > numSamp = 1000; > epsilon = matrix(rnorm(n*numSamp),n) > xCovar = matrix(c(1,1.5,1.5,3),2,2) > X = cbind(rep(1,n),rmvnorm(n, cbind(1,2),xCovar), runif(n, min = 0, max = 10)) > k = ncol(X) > Xnew = cbind(X[1,],X[3,],X[4,]) > y = matrix(0,n,numSamp) > beta_ols = matrix(0,k,numSamp) > > for (it in 1:numSamp) { + y[,it] = X%*%trueBeta + epsilon[,it] + beta_ols[,it] = solve(t(Xnew)%*%Xnew)%*%t(Xnew)%*%y[,it]} Error in solve(t(Xnew) %*% Xnew) %*% t(Xnew) %*% y[, it] : non-conformable arguments
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started