/* writedata_ols.c -- Writes out a file for ols_read.c. The X matrix
* is random data, the BETA vector is pre-set, and Y vector ix X*BETA.
* The first column is Y, the second is a column of "1"s for the
* intercept, and the remaing columns are drawn from the rand()
* function. User sets number of columns and number of rows below. */
#include
#include
/* Declare pointer to the output file */
FILE *kp;
int main(void){
int nrow=1000, ncol=25;
double *X, *Y, *BETA;
double sum;
int i = 0;
int j = 0;
X = (double *) malloc (nrow*ncol*sizeof(double));
Y = (double *) malloc (nrow*sizeof(double));
BETA = (double *) malloc (ncol*sizeof(double));
/* Open the output file */
kp = fopen("data_ols.txt","w");
printf("\nnumber of rows = %d number of columns = %d\n\n",nrow,ncol);
/* Initialize BETA vector -- Note that the Constant term will be
* affected by the means of the variables when OLS.c is run */
for(j=0;j