Skip to content

Function input for regression analysis

5 messages · R. Michael Weylandt, flokke, Bert Gunter

#
Dear all,
I have a small question.
I would like to write a function for a regression analysis that an be
applied to every dataset.
Now my problem is that I do not know what I have to implement then as input
for the function

mytest <- function (x,y) {
                                    beta <- solve(t(x)%*%x%*%t(x)%*%y

                                    (....)
                                   }

would not make any sense, because then you could only use a dataset with y
and one predictor,
but I just dont know how to do this in another way.

Has someone any idea?

Thanks a lot!
Cheers, Maria

--
View this message in context: http://r.789695.n4.nabble.com/Function-input-for-regression-analysis-tp3955611p3955611.html
Sent from the R help mailing list archive at Nabble.com.
#
Have you seen the lm() function? I think it does what you are talking
about, but the vagueries of your statement make it hard for me to give
a concrete answer. It does worry me to think of you having one
function to do all your regressions analysis ever for any problem
whatsoever....

Michael
On Mon, Oct 31, 2011 at 8:13 AM, flokke <flokke at live.de> wrote:
#
I know the lm() function, but I'd like to make my 'own' regression analysis
by using matrix algebra. 
Thats why I wrote the function, 
but I dont know what values to pick to make it suitable for every dataset. 

If I pick a statistical model like lm(y~x) as input, the function would not
know what objects it had to use
for the matrix algebra.

--
View this message in context: http://r.789695.n4.nabble.com/Function-input-for-regression-analysis-tp3955611p3956240.html
Sent from the R help mailing list archive at Nabble.com.