Modérateur : Groupe des modérateurs
Code : Tout sélectionner
>objet[]
Code : Tout sélectionner
>objet$nom
Code : Tout sélectionner
>names(objet)
Code : Tout sélectionner
> codaobject[]
[[1]]
Markov Chain Monte Carlo (MCMC) output:
Start = 101
End = 103
Thinning interval = 1
v
101 12
102 12
103 12
[[2]]
Markov Chain Monte Carlo (MCMC) output:
Start = 101
End = 103
Thinning interval = 1
v
101 12
102 24
103 32
[[3]]
Markov Chain Monte Carlo (MCMC) output:
Start = 101
End = 103
Thinning interval = 1
v
101 4
102 4
103 3
attr(,"class")
[1] "mcmc.list"
Code : Tout sélectionner
> codaobject[1,]
[[1]]
[1] 12
[[2]]
[1] 12
[[3]]
[1] 4
Code : Tout sélectionner
> typeof(codaobject)
[1] "list"
> class(codaobject)
[1] "mcmc.list"
> mode(codaobject)
[1] "list"
Code : Tout sélectionner
> codaobject[1,]
[[1]]
[1] 12
[[2]]
[1] 12
[[3]]
[1] 4
Moi je voudrais le vecteur (12,12,4). Je ne comprends pas les machins genre [[1]] :roll:
Code : Tout sélectionner
unlist( codaobject[1,] )
Code : Tout sélectionner
> x <- 1:10
> y <- rnorm(10)
> m <- lm(y ~ x)
> str(m)
List of 12
$ coefficients : Named num [1:2] 0.700 -0.154
..- attr(*, "names")= chr [1:2] "(Intercept)" "x"
$ residuals : Named num [1:10] 0.627 -0.443 0.291 -0.667 -1.197 ...
..- attr(*, "names")= chr [1:10] "1" "2" "3" "4" ...
$ effects : Named num [1:10] 0.473 -1.403 0.213 -0.796 -1.377 ...
..- attr(*, "names")= chr [1:10] "(Intercept)" "x" "" "" ...
$ rank : int 2
$ fitted.values: Named num [1:10] 0.5453 0.3909 0.2365 0.0820 -0.0724 ...
..- attr(*, "names")= chr [1:10] "1" "2" "3" "4" ...
$ assign : int [1:2] 0 1
$ qr :List of 5
..$ qr : num [1:10, 1:2] -3.162 0.316 0.316 0.316 0.316 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:10] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:2] "(Intercept)" "x"
.. ..- attr(*, "assign")= int [1:2] 0 1
..$ qraux: num [1:2] 1.32 1.27
..$ pivot: int [1:2] 1 2
..$ tol : num 1e-07
..$ rank : int 2
..- attr(*, "class")= chr "qr"
$ df.residual : int 8
$ xlevels : list()
$ call : language lm(formula = y ~ x)
$ terms :Classes 'terms', 'formula' length 3 y ~ x
.. ..- attr(*, "variables")= language list(y, x)
.. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:2] "y" "x"
.. .. .. ..$ : chr "x"
.. ..- attr(*, "term.labels")= chr "x"
.. ..- attr(*, "order")= int 1
.. ..- attr(*, "intercept")= int 1
.. ..- attr(*, "response")= int 1
.. ..- attr(*, ".Environment")=length 6 <environment>
.. ..- attr(*, "predvars")= language list(y, x)
.. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric"
.. .. ..- attr(*, "names")= chr [1:2] "y" "x"
$ model :'data.frame': 10 obs. of 2 variables:
..$ y: num [1:10] 1.1725 -0.0519 0.5270 -0.5848 -1.2691 ...
..$ x: int [1:10] 1 2 3 4 5 6 7 8 9 10
..- attr(*, "terms")=Classes 'terms', 'formula' length 3 y ~ x
.. .. ..- attr(*, "variables")= language list(y, x)
.. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : chr [1:2] "y" "x"
.. .. .. .. ..$ : chr "x"
.. .. ..- attr(*, "term.labels")= chr "x"
.. .. ..- attr(*, "order")= int 1
.. .. ..- attr(*, "intercept")= int 1
.. .. ..- attr(*, "response")= int 1
.. .. ..- attr(*, ".Environment")=length 6 <environment>
.. .. ..- attr(*, "predvars")= language list(y, x)
.. .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric"
.. .. .. ..- attr(*, "names")= chr [1:2] "y" "x"
- attr(*, "class")= chr "lm"
Code : Tout sélectionner
str(codaobject)
List of 3
$ : mcmc [1:9, 1:2] 109 108 108 108 108 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:9] "2" "3" "4" "5" ...
.. ..$ : chr [1:2] "deviance" "theta"
..- attr(*, "mcpar")= num [1:3] 2 10 1
..- attr(*, "class")= chr "mcmc"
$ : mcmc [1:9, 1:2] 108 108 108 109 108 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:9] "2" "3" "4" "5" ...
.. ..$ : chr [1:2] "deviance" "theta"
..- attr(*, "mcpar")= num [1:3] 2 10 1
..- attr(*, "class")= chr "mcmc"
$ : mcmc [1:9, 1:2] 108 108 108 108 108 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:9] "2" "3" "4" "5" ...
.. ..$ : chr [1:2] "deviance" "theta"
..- attr(*, "mcpar")= num [1:3] 2 10 1
..- attr(*, "class")= chr "mcmc"
- attr(*, "class")= chr "mcmc.list"
Code : Tout sélectionner
> codaobject[[1]]
Markov Chain Monte Carlo (MCMC) output:
Start = 2
End = 10
Thinning interval = 1
deviance theta
2 108.8 0.1907
3 108.0 0.2143
4 107.9 0.2279
5 107.9 0.2299
6 107.9 0.2285
7 112.7 0.3303
8 107.9 0.2309
9 108.2 0.2046
10 108.0 0.2432
Code : Tout sélectionner
> str(codaobject[[1]])
mcmc [1:9, 1:2] 109 108 108 108 108 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:9] "2" "3" "4" "5" ...
..$ : chr [1:2] "deviance" "theta"
- attr(*, "mcpar")= num [1:3] 2 10 1
- attr(*, "class")= chr "mcmc"
Code : Tout sélectionner
> codaobject[[1]][,1]
Markov Chain Monte Carlo (MCMC) output:
Start = 2
End = 10
Thinning interval = 1
2 3 4 5 6 7 8 9 10
108.8 108.0 107.9 107.9 107.9 112.7 107.9 108.2 108.0
Code : Tout sélectionner
> v<-codaobject[[1]][,1]
> v[3]
4
107.9
Code : Tout sélectionner
l<-length(v)
w<-rep(0,l)
for(i in 1:l){
w[i]<-v[i]
}
Je pense que tu peux solutionner ton problème en rendant les attributes de v NULL :il y a des informations en plus dans v
Code : Tout sélectionner
attributes(v) <- NULL
Retourner vers « Questions en cours »
Utilisateurs parcourant ce forum : Google [Bot] et 1 invité