Skip to main content

Posts

Featured

Estimating the OLS coeffcients , constructing a linear model and calculating the MSE using Cross validation

Here's My very first technical blog post!!!! Since I am a beginner in R, I found the problem quite overwhelming at first. It was partly because I was searching for the wrong stuff.      So it took me fairly long to figure out how to go about it. There are several in-built functions in R to construct a linear regression model and perform a Cross validation. The following is the shortest code to do that: You need to create a data frame of the dataset as follows fitData <- data.frame(OLStrain$Y, OLStrain$X1......) Don't forget to name the columns: names(fitData) <- c("Y","X1",...........) Now we create a linear model: This post talks about fitting an ordinary linear model with Y  as the response and X1, X2, X3....(the number of variables in your problem) as the predictors. This is done as follows: m1 <- lm(Y ~ .,data=fitData) To learn more about linear models, and the different parameters that you canplay around with, here are th

Latest Posts

My first post