This is a test version of Biostars. For the public version, visit https://www.biostars.org.
does the multiple linear regression from glmnet generate a formula?

Hello I have been using the package glmnet do multiple linear regression with different regularizations. I am a biologist though, so I don't understand the math behind it deeply. However, being a linear regression, I assume it generates a line to fit the data as best as possible, is that correct? In this case, shouldn't this line have a formula? If so, how could I get it? I intend to use it in a validation set to calculate the sensitivity and specificity.

EDIT

Here is an example of what I mean

In this figure I have table X with my explanatory variables, table y with my response values and, lastly, the coefficients given by multiple linear regression with lasso regularization from the package glmnet.

https://imgbbb.com/image/zgLnt

I assumed the formula y = "A" * 1 + "B" * 2 + "C" * 2 + "D" * 3 + "E" * 9

would give me back the response value, which would be 1. In this case, I get a y which is very closely related to the real value. However, in the models that I'm trying to fit, I am not. Am I doing the calculation right, or is the model I am using just bad?

ridge multiple linear regression lasso glmnet

In the most recent versions of glmnet, you can provide a formula to the function.

amazing! can you share a tutorial on how to do this?

The code I have been using is pretty much like this

Y1 <- as.matrix(Y)
is.matrix(Y1)
X1 <- as.matrix(X)
is.matrix(SurvivalX1)
CV = cv.glmnet(x=X2, y=Y1, family= "gaussian", type.measure = "mae", alpha = 0)
  ##

plot(CV)
  ## 

fit = (glmnet(x=X2, y=Y1, family= "gaussian", alpha=0, lambda=CV$lambda.1se))

##

fit$beta[,1]
ridge <- as.matrix(fit$beta)
write.table(ridge, "C:/Users/Diogo/Documents/masters/Ageing and adipose tissue/Ridge data/ridge.txt", sep="\t")

plot(fit, label = TRUE)
plot(fit)
print(fit)

write.table

amazing! can you share a tutorial on how to do this?

Dude... follow the links provided by cpad0112...

Thank you for the links

unfortunately, I believe the formulas and validations he refers to are no the same I am. What I am looking for exactly is a formula that uses explanatory variables so I can predict the response variable, for example like this

yi = B0 + B1xi1 + B2xi2 + ... where y is a response variable x are the explanatory variables B their correlation and B0 the height etc

Thank you cpad and kevin for the responses, extremely helpful. I wanted to leave a thanks here for the rest of us that are actually thankful for helping the newbies.

0 answers

No answers yet.

Log in to answer this question.