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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!