[R] estimating parameters

saira hashmi shashmi at gmail.com
Thu May 11 08:19:15 CEST 2006


Hi ,
I have a data set and I am trying to get the nonlinear least-squares
estimates of the nonlinear
model parameters .
I have tried nls, gls but seems like i am not able to get it to work. I have
attached the data set.

This is how I am doing. plz lemme knwo how to get it to work
Thanks

mlo.1 <- as.matrix(read.table("sio_co2_mlo_trans.txt",header=T))

y.ppm<-mlo.1[,"mlo"]

t2.yr<-mlo.1[,1] + mlo.1[,2]/13 #decimal fraction

mlo.input<-data.frame(mlo.ppm=mlo.1[,"mlo"],t2.yr=t2.yr)

mod<-nlsModel(y.ppm ~ (C1 + C2 * exp(C3 * t2.yr) + (1 + g * t2.yr) * (a1 *
sin(2*pi*t2.yr) + b1 * cos(2*pi*t2.yr)+ a2 * sin(4*pi*t2.yr) + b2 *
cos(4*pi*t2.yr)

+ a3 *sin(6*pi*t2.yr) + b3 * cos(6*pi*t2.yr) + a4 * sin(8*pi*t2.yr) + b4 *
cos(8*pi*t2.yr))),

data=as.data.frame(mlo.input),start=list(C1=250,C2=20,C3=.05,

g=.04,a1=1,b1=1,a2=1, b2 =1, a3=1, b3=1, a4=1, b4=1))
==============================
using gls ( I dont know how to make the above long equations work in gls.


fm1<-gls(y.ppm ~ t2.yr + sin(2*pi*t2.yr) + cos(2*pi*t2.yr),

data=as.data.frame(mlo.input))






On 5/10/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
>
> Try this:
>
> pmax(tmax.m[,1], tmax.m[,2], na.rm = TRUE)
>
>
> On 5/10/06, Dale Steele <Dale_Steele at brown.edu> wrote:
> > Hello -- Given the 10x2 matrix below, my goal is to create a vector
> > which contains the maximum of column 1 and column 2, or the only value
> > if there is an NA in one column.  I experimented with max.col without
> > success.  Thanks.  --Dale
> >
> >  > > tmax.m
> >        tmaxhme tmaxer
> >   [1,]   101.0   99.8
> >   [2,]   102.5   99.0
> >   [3,]   100.6   98.4
> >   [4,]      NA  100.5
> >   [5,]   101.0   99.4
> >   [6,]      NA   97.6
> >   [7,]      NA   99.0
> >   [8,]    99.0   98.4
> >   [9,]      NA   98.5
> >  [10,]      NA   99.1
> >
> > ______________________________________________
> > R-help at 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-help at 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
>
-------------- next part --------------
Year	month	 mlo
1959	1	315.58
1959	2	316.47
1959	3	316.65
1959	4	317.71
1959	5	318.29
1959	6	318.16
1959	7	316.55
1959	8	314.8
1959	9	313.84
1959	10	313.34
1959	11	314.81
1959	12	315.59
1960	1	316.43
1960	2	316.97
1960	3	317.58
1960	4	319.03
1960	5	320.03
1960	6	319.59
1960	7	318.18
1960	8	315.91
1960	9	314.16
1960	10	313.83
1960	11	315
1960	12	316.19
1961	1	316.89
1961	2	317.7
1961	3	318.54
1961	4	319.48
1961	5	320.58
1961	6	319.78
1961	7	318.58
1961	8	316.79
1961	9	314.99
1961	10	315.31
1961	11	316.1
1961	12	317.01
1962	1	317.94
1962	2	318.56
1962	3	319.69
1962	4	320.58
1962	5	321.01
1962	6	320.61
1962	7	319.61
1962	8	317.4
1962	9	316.26
1962	10	315.42
1962	11	316.69
1962	12	317.69
1963	1	317.94
1963	2	318.56
1963	3	319.69
1963	4	320.58
1963	5	321.01
1963	6	320.61
1963	7	319.61
1963	8	317.4
1963	9	316.26
1963	10	315.42
1963	11	316.69
1963	12	317.69
1964	1	318.74
1964	2	319.08
1964	3	319.86
1964	4	321.39
1964	5	322.24
1964	6	321.47
1964	7	319.74
1964	8	317.77
1964	9	316.21
1964	10	315.99
1964	11	317.07
1964	12	318.36
1965	1	319.57
1965	2	320.235 
1965	3	320.900 
1965	4	321.565 
1965	5	322.23
1965	6	321.89
1965	7	320.44
1965	8	318.7
1965	9	316.7
1965	10	316.87
1965	11	317.68
1965	12	318.71
1966	1	319.44
1966	2	320.44
1966	3	320.89
1966	4	322.13
1966	5	322.16
1966	6	321.87
1966	7	320.44
1966	8	318.87
1966	9	317.81
1966	10	317.3
1966	11	318.87
1966	12	319.42
1967	1	320.62
1967	2	321.59
1967	3	322.39
1967	4	323.7
1967	5	324.07
1967	6	323.75
1967	7	320.44
1967	8	320.37
1967	9	318.64
1967	10	318.1
1967	11	319.79
1967	12	321.03
1968	1	322.57
1968	2	323.15
1968	3	323.89
1968	4	325.02
1968	5	325.57
1968	6	325.36
1968	7	324.14
1968	8	322.11
1968	9	320.33
1968	10	320.25
1968	11	321.32
1968	12	322.9
1969	1	324
1969	2	324.42
1969	3	325.64
1969	4	326.66
1969	5	327.38
1969	6	326.7
1969	7	325.89
1969	8	323.67
1969	9	322.38
1969	10	321.78
1969	11	322.85
1969	12	324.12
1970	1	325.06
1970	2	325.98
1970	3	326.93
1970	4	328.13
1970	5	328.07
1970	6	327.66
1970	7	326.35
1970	8	324.69
1970	9	323.1
1970	10	323.07
1970	11	324.01
1970	12	325.13
1971	1	326.17
1971	2	326.68
1971	3	327.18
1971	4	327.78
1971	5	328.92
1971	6	328.57
1971	7	327.37
1971	8	325.43
1971	9	323.36
1971	10	323.56
1971	11	324.8
1971	12	326.01
1972	1	326.77
1972	2	327.63
1972	3	327.75
1972	4	329.72
1972	5	330.07
1972	6	329.09
1972	7	328.05
1972	8	326.32
1972	9	324.84
1972	10	325.2
1972	11	326.5
1972	12	327.55
1973	1	328.54
1973	2	329.56
1973	3	330.3
1973	4	331.5
1973	5	332.48
1973	6	332.07
1973	7	330.87
1973	8	329.31
1973	9	327.51
1973	10	327.18
1973	11	328.16
1973	12	328.64
1974	1	329.35
1974	2	330.71
1974	3	331.48
1974	4	332.65
1974	5	333.09
1974	6	332.25
1974	7	331.18
1974	8	329.4
1974	9	327.44
1974	10	327.37
1974	11	328.46
1974	12	329.58
1975	1	330.4
1975	2	331.41
1975	3	332.04
1975	4	333.31
1975	5	333.96
1975	6	333.59
1975	7	331.91
1975	8	330.06
1975	9	328.56
1975	10	328.34
1975	11	329.49
1975	12	330.76
1976	1	331.74
1976	2	332.56
1976	3	333.5
1976	4	334.58
1976	5	334.87
1976	6	334.34
1976	7	333.05
1976	8	330.94
1976	9	329.3
1976	10	328.94
1976	11	330.31
1976	12	331.68
1977	1	332.92
1977	2	333.42
1977	3	334.7
1977	4	336.07
1977	5	336.74
1977	6	336.27
1977	7	334.93
1977	8	332.75
1977	9	331.58
1977	10	331.16
1977	11	332.4
1977	12	333.85
1978	1	334.97
1978	2	335.39
1978	3	336.64
1978	4	337.76
1978	5	338.01
1978	6	337.89
1978	7	336.54
1978	8	334.68
1978	9	332.76
1978	10	332.54
1978	11	333.92
1978	12	334.95
1979	1	336.23
1979	2	336.76
1979	3	337.96
1979	4	338.89
1979	5	339.47
1979	6	339.29
1979	7	337.73
1979	8	336.09
1979	9	333.91
1979	10	333.86
1979	11	335.29
1979	12	336.73
1980	1	338.01
1980	2	338.36
1980	3	340.08
1980	4	340.77
1980	5	341.46
1980	6	341.17
1980	7	339.56
1980	8	337.6
1980	9	335.88
1980	10	336.01
1980	11	337.1
1980	12	338.21
1981	1	339.23
1981	2	340.47
1981	3	341.38
1981	4	342.51
1981	5	342.91
1981	6	342.25
1981	7	340.49
1981	8	338.43
1981	9	336.69
1981	10	336.85
1981	11	338.36
1981	12	339.61
1982	1	340.75
1982	2	341.61
1982	3	342.7
1982	4	343.56
1982	5	344.13
1982	6	343.35
1982	7	342.06
1982	8	339.82
1982	9	337.97
1982	10	337.86
1982	11	339.26
1982	12	340.49
1983	1	341.37
1983	2	342.52
1983	3	343.1
1983	4	344.94
1983	5	345.75
1983	6	345.32
1983	7	343.99
1983	8	342.39
1983	9	339.86
1983	10	339.99
1983	11	341.16
1983	12	342.99
1984	1	343.7
1984	2	344.51
1984	3	345.28
1984	4	347.08
1984	5	347.43
1984	6	346.79
1984	7	345.4
1984	8	343.28
1984	9	341.07
1984	10	341.35
1984	11	342.98
1984	12	344.22
1985	1	344.97
1985	2	346
1985	3	347.43
1985	4	348.35
1985	5	348.93
1985	6	348.25
1985	7	346.56
1985	8	344.69
1985	9	343.09
1985	10	342.8
1985	11	344.24
1985	12	345.56
1986	1	346.29
1986	2	346.96
1986	3	347.86
1986	4	349.55
1986	5	350.21
1986	6	349.54
1986	7	347.94
1986	8	345.91
1986	9	344.86
1986	10	344.17
1986	11	345.66
1986	12	346.9
1987	1	348.02
1987	2	348.47
1987	3	349.42
1987	4	350.99
1987	5	351.84
1987	6	351.25
1987	7	349.52
1987	8	348.1
1987	9	346.44
1987	10	346.36
1987	11	347.81
1987	12	348.96
1988	1	350.43
1988	2	351.72
1988	3	352.22
1988	4	353.59
1988	5	354.22
1988	6	353.79
1988	7	352.39
1988	8	350.44
1988	9	348.72
1988	10	348.88
1988	11	350.07
1988	12	351.34
1989	1	352.76
1989	2	353.07
1989	3	353.68
1989	4	355.42
1989	5	355.67
1989	6	355.13
1989	7	353.9
1989	8	351.67
1989	9	349.8
1989	10	349.99
1989	11	351.3
1989	12	352.53
1990	1	353.66
1990	2	354.7
1990	3	355.39
1990	4	356.2
1990	5	357.16
1990	6	356.22
1990	7	354.82
1990	8	352.91
1990	9	350.96
1990	10	351.18
1990	11	352.83
1990	12	354.21
1991	1	354.72
1991	2	355.75
1991	3	357.16
1991	4	358.6
1991	5	359.34
1991	6	358.24
1991	7	356.17
1991	8	354.03
1991	9	352.16
1991	10	352.21
1991	11	353.75
1991	12	354.99
1992	1	355.98
1992	2	356.72
1992	3	357.81
1992	4	359.15
1992	5	359.66
1992	6	359.25
1992	7	357.03
1992	8	355
1992	9	353.01
1992	10	353.31
1992	11	354.16
1992	12	355.4
1993	1	356.7
1993	2	357.16
1993	3	358.38
1993	4	359.46
1993	5	360.28
1993	6	359.6
1993	7	357.57
1993	8	355.52
1993	9	353.7
1993	10	353.98
1993	11	355.33
1993	12	356.8
1994	1	358.36
1994	2	358.91
1994	3	359.97
1994	4	361.26
1994	5	361.68
1994	6	360.95
1994	7	359.55
1994	8	357.49
1994	9	355.84
1994	10	355.99
1994	11	357.58
1994	12	359.04
1995	1	359.96
1995	2	361
1995	3	361.64
1995	4	363.45
1995	5	363.79
1995	6	363.26
1995	7	361.9
1995	8	359.46
1995	9	358.06
1995	10	357.75
1995	11	359.56
1995	12	360.7
1996	1	362.05
1996	2	363.25
1996	3	364.03
1996	4	364.72
1996	5	365.41
1996	6	364.97
1996	7	363.65
1996	8	361.49
1996	9	359.46
1996	10	359.6
1996	11	360.76
1996	12	362.33
1997	1	363.18
1997	2	364
1997	3	364.57
1997	4	366.35
1997	5	366.79
1997	6	365.62
1997	7	364.47
1997	8	362.51
1997	9	360.19
1997	10	360.77
1997	11	362.43
1997	12	364.28
1998	1	365.32
1998	2	366.15
1998	3	367.31
1998	4	368.61
1998	5	369.29
1998	6	368.87
1998	7	367.64
1998	8	365.77
1998	9	363.9
1998	10	364.23
1998	11	365.46
1998	12	366.97
1999	1	368.15
1999	2	368.87
1999	3	369.59
1999	4	371.14
1999	5	371
1999	6	370.35
1999	7	369.27
1999	8	366.94
1999	9	364.63
1999	10	365.12
1999	11	366.67
1999	12	368.01
2000	1	369.14
2000	2	369.46
2000	3	370.52
2000	4	371.66
2000	5	371.82
2000	6	371.7
2000	7	370.12
2000	8	368.12
2000	9	366.62
2000	10	366.73
2000	11	368.29
2000	12	369.53
2001	1	370.28
2001	2	371.5
2001	3	372.12
2001	4	372.87
2001	5	374.02
2001	6	373.3
2001	7	371.62
2001	8	369.55
2001	9	367.96
2001	10	368.09
2001	11	369.68
2001	12	371.24
2002	1	372.43
2002	2	373.09
2002	3	373.52
2002	4	374.86
2002	5	375.55
2002	6	375.41
2002	7	374.02
2002	8	371.49
2002	9	370.71
2002	10	370.25
2002	11	372.08
2002	12	373.78
2003	1	374.68
2003	2	375.63
2003	3	376.11
2003	4	377.65
2003	5	378.35
2003	6	378.13
2003	7	376.62
2003	8	374.5
2003	9	372.99
2003	10	373
2003	11	374.35
2003	12	375.7
2004	1	376.79
2004	2	377.37
2004	3	378.41
2004	4	380.52
2004	5	380.63
2004	6	379.57
2004	7	377.79
2004	8	375.86
2004	9	374.06
2004	10	374.24
2004	11	375.86
2004	12	377.48




More information about the R-help mailing list