0

在下面给出的 gls 输出中,如何从 gls 对象中提取参数估计值 1.000000 3.913972 10.684698 11.350910 26.476561 27.255072 并将它们分配给另一个变量?

> m
    X     Y  F
1   1  1.07  1
2   1  1.01  1
3   1  0.99  1
4   1  1.09  1
5   1  0.94  1
6   1  1.00  1
7   1  1.01  1
8   1  0.98  1
9   1  1.00  1
10  1  1.03  1
11  4  3.66  4
12  4  3.75  4
13  4  3.77  4
14  4  3.92  4
15  4  4.08  4
16  4  3.99  4
17  4  3.95  4
18  4  4.10  4
19  4  3.88  4
20  4  4.04  4
21 10 10.13 10
22 10 10.20 10
23 10  9.77 10
24 10 10.28 10
25 10  8.71 10
26 10  9.79 10
27 10  9.82 10
28 10  9.85 10
29 10 10.07 10
30 10  9.63 10
31 20 20.22 20
32 20 19.46 20
33 20 19.02 20
34 20 20.06 20
35 20 20.94 20
36 20 19.92 20
37 20 19.96 20
38 20 20.04 20
39 20 19.67 20
40 20 19.96 20
41 30 31.04 30
42 30 31.40 30
43 30 31.84 30
44 30 30.77 30
45 30 32.13 30
46 30 31.17 30
47 30 30.36 30
48 30 29.95 30
49 30 30.74 30
50 30 30.67 30
51 40 41.14 40
52 40 40.29 40
53 40 42.77 40
54 40 38.36 40
55 40 39.17 40
56 40 39.61 40
57 40 40.73 40
58 40 39.42 40
59 40 40.72 40
60 40 40.24 40
> Fit.gls <- gls(Y ~ X,weights=varIdent(form = ~ 1 | F),data=m)
> summary(Fit.gls)
Generalized least squares fit by REML
  Model: Y ~ X 
  Data: m 
       AIC      BIC    logLik
  78.96207 95.44562 -31.48104

Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | F 
 Parameter estimates:
        1         4        10        20        30        40 
 1.000000  3.913972 10.684698 11.350910 26.476561 27.255072 
4

1 回答 1

2

这会给你想要的吗?

x <- Fit.gls$model
coef(x, unconstrained=FALSE) 
#  varStruct.4 varStruct.10 varStruct.20 varStruct.30 varStruct.40 
#     3.913972    10.684698    11.350910    26.476561    27.255072 
于 2013-04-12T12:08:32.647 回答