Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

=+from: a) a MNEs perspective? and b) the HRM managers perspective?

Answered: 1 week ago