Re: [R] Model formula question
Not sure why you feel the need to use gnm here - are you working with non-normal data? From your description it would seem that nls is more appropriate, Heather Dr H Turner Research Fellow Dept. of Statistics The University of Warwick Coventry CV4 7AL Tel: 024 76575870 Fax: 024 76524532 Url: www.warwick.ac.uk/go/heatherturner From: Ronaldo Prati [mailto:[EMAIL PROTECTED] Sent: Thu 14/12/2006 13:41 To: r-help@stat.math.ethz.ch Subject: [R] Model formula question Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. .. y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u .. ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Model formula question
[resend - hopefully HTML switched off this time] Not sure why you feel the need to use gnm here - are you working with non-normal data? From your description it would seem that nls is more appropriate, Heather Dr H Turner Research Fellow Dept. of Statistics The University of Warwick Coventry CV4 7AL Tel: 024 76575870 Fax: 024 76524532 Url: www.warwick.ac.uk/go/heatherturner -Original Message- From: Ronaldo Prati [mailto:[EMAIL PROTECTED] Sent: Thu 14/12/2006 13:41 To: r-help@stat.math.ethz.ch Subject: [R] Model formula question Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. .. y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u .. ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Model formula question
Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. ... y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u ... ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Model formula question
Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. ... y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u ... ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Model formula
Hi there, I've sent this e-mail to the list twice but didn't get it back from the list. Have it reach list members? cheers, Ronaldo -- Forwarded message -- From: Ronaldo Prati [EMAIL PROTECTED] Date: 14/12/2006 11:59 Subject: Model formula question To: r-help@stat.math.ethz.ch Hi all, I'm not familiar with R programming and I'm trying to reproduce a result from a paper. Basically, I have a dataset which I would like to model in terms of successive increments, i.e. (y denote empirical values of y) y_1 = y1, y_2 = y1 + delta1, y_3 = y1 + delta1 + delta2. ... y_m = y1 + sum_2^m delta j where delta_j donote successive increments in the y-values, i.e. delta j = y_j - y_(j-1). In order to estimate y-values, I'm assuming that delta j is approximately equal to kj**u, such that my regression model should be something like this: ^y_1 = a1 ^y_2 = a1 + k2**u ^y_3 = a1 + k2**u + k3**u ... ^y_m = a1 + k2**u + k3**u + ... + km**u or, generically ^yi = a1 + k * sum_j=2^i j**u and I need to fit a non-linear least-squares regression model to find the tripplet a1,k,u. I had a look to the gnm package, but I don't have the lesser idea how to formulate this problem to use this package. Can someone help me with that? cheers, Ronaldo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] : Model formula question
On Wednesday 01 February 2006 02:37, maneesh deshpande wrote: Hi, I have a data set with a continuous predictor X, a factor A and a continuous dependent variable Y. I am trying to build a linear model of the form: Y = (b0 + b1*X1)*B(A) where B(A) is a constant for each level of the factor A. I am not quite sure how to formulate the appropriate model formula. If I write: Y ~ ( 1 + X)/A , I get estimates for as many constants and slopes as the number of levels of A. Yes, that's right: the / symbol has a special (non-arithmetic) meaning when used like this in a model formula. See for example p151 onwards in the reference that is given by ?formula. What I really need is an overall multiplicative constant which depends on the factor A. The gnm (generalized nonlinear models) package has facilities for this. The model above could be specified there as Y ~ -1 + Mult(X, -1 + A) (where the first -1 removes the intercept, and the second one says to estimate a separate multiplier for each level of A rather than using contrasts in A). Or, if you want to constrain all of your multipliers to have the same sign, you can use Y ~ -1 + Mult(X, Exp(-1 + A)) (note the capital E there!). It is unclear to me that using the *same* set of multipliers for both intercept and slope will typically be the right thing to do, though. It would not, for example, be invariant to transformation of X to X-c, with c constant. That is to say, your X variable needs to be on a scale for which the zero value has a special meaning, in order to allow the above model to make sense. But presumably you have thought about this already. Hoping that helps, David -- Professor David Firth http://www.warwick.ac.uk/go/dfirth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] : Model formula question
Hi, I have a data set with a continuous predictor X, a factor A and a continuous dependent variable Y. I am trying to build a linear model of the form: Y = (b0 + b1*X1)*B(A) where B(A) is a constant for each level of the factor A. I am not quite sure how to formulate the appropriate model formula. If I write: Y ~ ( 1 + X)/A , I get estimates for as many constants and slopes as the number of levels of A. What I really need is an overall multiplicative constant which depends on the factor A. Thanks in advance, Maneesh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] model formula
I have continuous variables x, y, z. The plot of the data looks like this: y | z=1(o), 2(@), 3(#), 4(*) | |* * * | | |# # # # | | |@@@ @ | | o | o | o | o |o x The correct model appears to be: if z==1, y~x+z; else y~z (y~z + z:x isn't it) How can I express this model in lm()? If I can't express it properly in lm(), what is the best way to fit the model? Thanks for any help. Bill Simpson __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] model formula
Bill Simpson [EMAIL PROTECTED] writes: I have continuous variables x, y, z. The plot of the data looks like this: y | z=1(o), 2(@), 3(#), 4(*) | |* * * | | |# # # # | | |@@@ @ | | o | o | o | o |o x The correct model appears to be: if z==1, y~x+z; else y~z (y~z + z:x isn't it) Not if z really is continuous... How can I express this model in lm()? If I can't express it properly in lm(), what is the best way to fit the model? I'd try something like x2 - ifelse(z==1, x, 0) z2 - factor(z) y ~ x2+z2 -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] model formula
Dear Bill, I believe that lm(y ~ z + I((z == 1)*x)) will give you what you want. I hope that this helps, John At 08:40 AM 11/18/2003 -0500, you wrote: I have continuous variables x, y, z. The plot of the data looks like this: y | z=1(o), 2(@), 3(#), 4(*) | |* * * | | |# # # # | | |@@@ @ | | o | o | o | o |o x The correct model appears to be: if z==1, y~x+z; else y~z (y~z + z:x isn't it) How can I express this model in lm()? If I can't express it properly in lm(), what is the best way to fit the model? John Fox Department of Sociology McMaster University email: [EMAIL PROTECTED] web: http://www.socsci.mcmaster.ca/jfox __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] model formula
Thanks very much John Peter for your help. Bill __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help