[R] model fitting with lme

2013-03-01 Thread KAYIS Seyit Ali
(Apologise for re-sending. I am re-sending in case subject name did not give 
enough information. Any shared experience with lme is deeply appreciated)

Dear all, 
 
I have data from the following experimental design and trying to fit a mixed 
model with lme function according to following steps but struggling. Any help 
is deeply appreciated.
 
1) Experimental design: I have 40 plants each of which has 4 clones. Each clone 
planted to one of 4 blocks. Phenotypes were collected from each clone for 3 
consecutive years. I have genotypes of plants. I need to relate phenotype to 
genotype. 
 
2) I am reading data from a file with “read.table” function. Then grouping 
data as: my.Data-groupedData( phenotype ~ Block | PlantID, data = 
as.data.frame( Data ) ) 
 
3) I want to fit Genotype + Year + Genotype:Year as fixed effect. Block + 
PlantID + Block.PlantID as random effect. 
 
I feel my data grouping is incorrect as model fitting do not work properly. 
 
Any help regarding data grouping and model fitting is deeply appreciated.
 
Kind Regards
 
Seyit Ali
 



Dr. Seyit Ali KAYIS
Selcuk University, Faculty of Agriculture
Kampus/Konya, Turkey



Tel: +90 332 223 2830 Mobile: +90 535 587 1139


Greetings from Konya, Turkey
http://www.ziraat.selcuk.edu.tr/skayis/

[[alternative HTML version deleted]]

__
R-help@r-project.org 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 fitting with lme

2013-03-01 Thread Bert Gunter
You did not get any replies because this is largely off topic. Please
stop posting here and post to the r-sig-mixed-models list instead.

-- Bert

On Fri, Mar 1, 2013 at 9:33 AM, KAYIS Seyit Ali s_a_ka...@yahoo.com wrote:
 (Apologise for re-sending. I am re-sending in case subject name did not give 
 enough information. Any shared experience with lme is deeply appreciated)

 Dear all,

 I have data from the following experimental design and trying to fit a mixed 
 model with lme function according to following steps but struggling. Any help 
 is deeply appreciated.

 1) Experimental design: I have 40 plants each of which has 4 clones. Each 
 clone planted to one of 4 blocks. Phenotypes were collected from each clone 
 for 3 consecutive years. I have genotypes of plants. I need to relate 
 phenotype to genotype.

 2) I am reading data from a file with “read.table” function. Then grouping 
 data as: my.Data-groupedData( phenotype ~ Block | PlantID, data = 
 as.data.frame( Data ) )

 3) I want to fit Genotype + Year + Genotype:Year as fixed effect. Block + 
 PlantID + Block.PlantID as random effect.

 I feel my data grouping is incorrect as model fitting do not work properly.

 Any help regarding data grouping and model fitting is deeply appreciated.

 Kind Regards

 Seyit Ali



 
 Dr. Seyit Ali KAYIS
 Selcuk University, Faculty of Agriculture
 Kampus/Konya, Turkey



 Tel: +90 332 223 2830 Mobile: +90 535 587 1139


 Greetings from Konya, Turkey
 http://www.ziraat.selcuk.edu.tr/skayis/
 
 [[alternative HTML version deleted]]


 __
 R-help@r-project.org 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.




-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org 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 fitting

2012-02-15 Thread Anthony Fristachi
Greetings,

Any suggestions for approaching the fitting of the function

y = b/exp(a*x) + c*x + y0
 
where a, b, c, and y0 are unknown constants and y and x are variables in a
give dataset.


Thanks


Tony



[[alternative HTML version deleted]]

__
R-help@r-project.org 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 fitting

2012-02-15 Thread Tsjerk Wassenaar
Hi Tony,

?nls

Cheers,

Tsjerk

On Feb 15, 2012 8:03 PM, Anthony Fristachi antak...@gmail.com wrote:

Greetings,

Any suggestions for approaching the fitting of the function

y = b/exp(a*x) + c*x + y0

where a, b, c, and y0 are unknown constants and y and x are variables in a
give dataset.


Thanks


Tony



   [[alternative HTML version deleted]]

__
R-help@r-project.org 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.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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 fitting

2010-09-15 Thread Diogo B. Provete
I have a data set and I want to procedure to model fitting (e.g., Poisson,
Gausian, binomial, quasipoisson etc.). I'd like to know if there is an
easier way to do this in R.

Thank you in advance.

-- 
Atenciosamente,
Diogo Borges Provete

==
Biólogo
Mestre em Biologia Animal (UNESP)
Laboratório de Ecologia Animal
Departamento de Zoologia e Botânica
Instituto de Biociências, Letras e Ciências Exatas
Universidade Estadual Paulista - UNESP
São José do Rio Preto-SP
Brazil

Rua Cristóvão Colombo, 2265
Jardim Nazareth -  15054-000

Skype: diogoprovete
MSN: diogop...@yahoo.com.br
==

[[alternative HTML version deleted]]

__
R-help@r-project.org 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 fitting

2010-09-15 Thread Erik Iverson



Diogo B. Provete wrote:

I have a data set and I want to procedure to model fitting (e.g., Poisson,
Gausian, binomial, quasipoisson etc.). I'd like to know if there is an
easier way to do this in R.


Easier than what ?

There is no shortage of R functions and packages to fit almost any type
of model that you're likely to encounter.

Start simple with ?lm and ?glm for linear models, and go from there.

There are dozens of books you can read to help you learn the packages,
depending on your level and field of expertise.

--Erik

__
R-help@r-project.org 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 fitting with GAM and by term

2009-06-24 Thread Gavin Simpson
On Tue, 2009-06-23 at 14:18 -0400, Paul Simonin wrote:
 Hello R Users,
  I have a question regarding fitting a model with GAM{mgcv}. I have data 
 from several predictor (X) variables I wish to use to develop a model to 
 predict one Y variable. I am working with ecological data, so have data 
 collected many times (about 20) over the course of two years. Plotting 
 data independently for each date there appears to be relationships 
 between Y (fish density) and at least several X variables (temperature 
 and light). However, the actual value of X variables (e.g., temperature) 
 changes with date/season. In other words, fish distribution is likely 
 related to temperature, but available temperatures change through the 
 season. Thus, when data from all dates are combined to create a model 
 from the entire dataset, I think I need to include some type of 
 metric/variable/interaction term to account for this date relationship. 
 I have written the following code using a by term:

A by smooth like this will produce a varying coefficient model, where a
separate smooth is fitted to the levels of the by variable. As unique
datecodes becomes large, this may be inefficient for the purposes you
have in mind - which as per several of your recent emails appears, is to
fit an interaction.

In mgcv, interactions can be fitted using a bivariate smooth of the two
variables of interest. Without your data or information on the structure
of datecode, it is difficult to suggest exactly how to proceed (and
perhaps why you haven't received replies to your postings), but if
datecode represents the day-of-year or the month (expressed as a
numeric) in which sampling took place, then an interaction between
datecode and temperature could be achieved using a tensor product
smooth:

te(temperature, datecode, bs = c(cr,cc))

I use a tensor product as we do not expect isotropy and the two
variables are on different scales. The bs species that temperature is a
cubic regression spline and that datecode is a cyclic cubic regression
spline so the end points join (i.e. you want smooth transition from
December to January). If your datecode variable does not got from month
1 (day-of-year 1) to month 12 (day-of-year 365(6)) then you might want
to specify the end-points so this smooth covers the full year. In your
call to gam, add argument 'knots'.

## for datecode === day-of-year one might use
knots = list(datecode = c(1, 365))
## for datecode === month, one might use
knots = list(datecode = c(1, 12))

i.e. with recent versions of mgcv (1.5-x branch) you can specify only
the start and end points of the smooth and gam fills in the knots up to
the chosen or default value of 'k' (the number of knots).

The te() smooth also needs version 1.5-5 of mgcv as there was a bug in
the code when setting up cc smooths in te() smooths that is fixed in
that version.

 
 Distribution.s.temp.logwm2.deltaT-gam(yoyras~s(temp,by=datecode)+s(logwm2,by=datecode)+s(DeltaT,by=datecode),data=AllData)
  

This seems completely over-specified -  you are asking the model to
estimate separate smooths for each value of datecode for each of three
covariates. You'll need lots of data to fit such a model.

 
  However, I am not convinced this is the correct way to account for this 
 relationship. What do you think? Is there another way to include this in 
 my model? Maybe I should simply include date (datecode) as another 
 term in the model?
 
  I also believe there may be an interaction between temperature and 
 light (logwm2), and based on what I have read the by method may be the 
 best way to include this. Correct?

In that case, temp, datecode and light will all be related via
interaction. te() smooths can take more than two covariates, so you
could try fitting a smooth on all three, but you are starting off with
quite a complicated model here.

I think, in general, interactions are fitted via multivariate smooths of
the variables of interest, not using by variables.

HTH

G

 
  Thank you for any input, tips, or advice you may be able to offer. I am 
 new to R, so especially grateful!
 
 Thanks again,
 Paul Simonin
 (PhD student)
 
 PS- If you would like additional information let me know. Also, if this 
 question is inappropriate for the help list please let me know.
 
 __
 R-help@r-project.org 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk

[R] Model fitting with GAM and by term

2009-06-23 Thread Paul Simonin

Hello R Users,
I have a question regarding fitting a model with GAM{mgcv}. I have data 
from several predictor (X) variables I wish to use to develop a model to 
predict one Y variable. I am working with ecological data, so have data 
collected many times (about 20) over the course of two years. Plotting 
data independently for each date there appears to be relationships 
between Y (fish density) and at least several X variables (temperature 
and light). However, the actual value of X variables (e.g., temperature) 
changes with date/season. In other words, fish distribution is likely 
related to temperature, but available temperatures change through the 
season. Thus, when data from all dates are combined to create a model 
from the entire dataset, I think I need to include some type of 
metric/variable/interaction term to account for this date relationship. 
I have written the following code using a by term:


Distribution.s.temp.logwm2.deltaT-gam(yoyras~s(temp,by=datecode)+s(logwm2,by=datecode)+s(DeltaT,by=datecode),data=AllData) 



However, I am not convinced this is the correct way to account for this 
relationship. What do you think? Is there another way to include this in 
my model? Maybe I should simply include date (datecode) as another 
term in the model?


I also believe there may be an interaction between temperature and 
light (logwm2), and based on what I have read the by method may be the 
best way to include this. Correct?


Thank you for any input, tips, or advice you may be able to offer. I am 
new to R, so especially grateful!


Thanks again,
Paul Simonin
(PhD student)

PS- If you would like additional information let me know. Also, if this 
question is inappropriate for the help list please let me know.

__
R-help@r-project.org 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 fitting using by(): how to get fitted values?

2009-05-06 Thread xavier . chardon
Hi all,

I'm doing nonlinear regressions on data with several factors. I want to fit say 
a logistic curve with different parameter values for each factor level. So I'm 
doing something like:

tmp - by( myData, list(myFactor1, myFactor2), function(x) nls(...) )

It works fine. However, I could not find an easy way to retrieve fitted values. 
I can use fitted() on each element of tmp, but that gives me as many vectors as 
there are combinations of factor levels.

I was thinking of using by() again, but I can't figure out how to write it 
properly.

Any ideas?


Thanks a lot,

Xavier

__
R-help@r-project.org 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 fitting using by(): how to get fitted values?

2009-05-06 Thread Duncan Murdoch

On 06/05/2009 8:22 AM, xavier.char...@free.fr wrote:

Hi all,

I'm doing nonlinear regressions on data with several factors. I want to fit say 
a logistic curve with different parameter values for each factor level. So I'm 
doing something like:

tmp - by( myData, list(myFactor1, myFactor2), function(x) nls(...) )

It works fine. However, I could not find an easy way to retrieve fitted values. 
I can use fitted() on each element of tmp, but that gives me as many vectors as 
there are combinations of factor levels.


I think lapply() (or maybe sapply) will do what you want.  I haven't 
tried this, but it should be something like


lapply(tmp, fitted)

Duncan Murdoch



I was thinking of using by() again, but I can't figure out how to write it 
properly.

Any ideas?


Thanks a lot,

Xavier

__
R-help@r-project.org 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-help@r-project.org 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.