This question already has an answer here:
I'm actually trying to extract the p-value from an oneway test which is an S4 type object. I tried every code i found but in this test p-value gives a formula.
This is what i get when i call my test:
> str(One1)
Formal class 'ScalarIndependenceTest' [package "coin"] with 7 slots
..@ parameter : chr "mu"
..@ nullvalue : num 0
..@ distribution:Formal class 'ApproxNullDistribution' [package "coin"] with 10 slots
.. .. ..@ seed : int [1:626] 403 38 1805567395 1288999595 1796387833 -1210691225 -851843786 571713292 970608248 -1588939275 ...
.. .. ..@ q :function (p)
.. .. ..@ d :function (x)
.. .. ..@ support :function (raw = FALSE)
.. .. ..@ parameters : list()
.. .. ..@ pvalue :function (q)
.. .. ..@ midpvalue :function (q)
.. .. ..@ pvalueinterval:function (q)
.. .. ..@ p :function (q)
.. .. ..@ name : chr "Monte Carlo Distribution"
..@ statistic :Formal class 'ScalarIndependenceTestStatistic' [package "coin"] with 15 slots
.. .. ..@ alternative : chr "two.sided"
.. .. ..@ paired : logi FALSE
.. .. ..@ teststatistic : Named num -6.66
.. .. .. ..- attr(*, "names")= chr "bas"
.. .. ..@ standardizedlinearstatistic: Named num -6.66
.. .. .. ..- attr(*, "names")= chr "bas"
.. .. ..@ linearstatistic : num 56.8
.. .. ..@ expectation : Named num 136
.. .. .. ..- attr(*, "names")= chr "bas"
.. .. ..@ covariance :Formal class 'Variance' [package "coin"] with 1 slot
.. .. .. .. ..@ variance: Named num 141
.. .. .. .. .. ..- attr(*, "names")= chr "bas"
.. .. ..@ xtrans : num [1:972, 1] 1 1 1 0 0 0 1 1 1 0 ...
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : chr [1:972] "1" "2" "3" "4" ...
.. .. .. .. ..$ : chr "bas"
.. .. .. ..- attr(*, "assign")= int 1
.. .. ..@ ytrans : num [1:972, 1] 0 0 0 0.638 0 ...
.. .. .. ..- attr(*, "assign")= int 1
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : chr ""
.. .. ..@ xtrafo :function (data, numeric_trafo = id_trafo, factor_trafo = f_trafo, ordered_trafo = of_trafo, surv_trafo = logrank_trafo,
var_trafo = NULL, block = NULL)
.. .. ..@ ytrafo :function (data, numeric_trafo = id_trafo, factor_trafo = f_trafo, ordered_trafo = of_trafo, surv_trafo = logrank_trafo,
var_trafo = NULL, block = NULL)
.. .. ..@ x :'data.frame': 972 obs. of 1 variable:
.. .. .. ..$ factor(vert): Factor w/ 2 levels "bas","haut": 1 1 1 2 2 2 1 1 1 2 ...
.. .. .. ..- attr(*, "terms")=Classes 'terms', 'formula' language ~factor(vert)
.. .. .. .. .. ..- attr(*, "variables")= language list(factor(vert))
.. .. .. .. .. ..- attr(*, "factors")= int [1, 1] 1
.. .. .. .. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. .. .. ..$ : chr "factor(vert)"
.. .. .. .. .. .. .. ..$ : chr "factor(vert)"
.. .. .. .. .. ..- attr(*, "term.labels")= chr "factor(vert)"
.. .. .. .. .. ..- attr(*, "order")= int 1
.. .. .. .. .. ..- attr(*, "intercept")= int 1
.. .. .. .. .. ..- attr(*, "response")= int 0
.. .. .. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. .. .. .. .. ..- attr(*, "predvars")= language list(factor(vert))
.. .. .. .. .. ..- attr(*, "dataClasses")= Named chr "factor"
.. .. .. .. .. .. ..- attr(*, "names")= chr "factor(vert)"
.. .. ..@ y :'data.frame': 972 obs. of 1 variable:
.. .. .. ..$ duree: num [1:972] 0 0 0 0.638 0 ...
.. .. .. ..- attr(*, "terms")=Classes 'terms', 'formula' language ~duree
.. .. .. .. .. ..- attr(*, "variables")= language list(duree)
.. .. .. .. .. ..- attr(*, "factors")= int [1, 1] 1
.. .. .. .. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. .. .. ..$ : chr "duree"
.. .. .. .. .. .. .. ..$ : chr "duree"
.. .. .. .. .. ..- attr(*, "term.labels")= chr "duree"
.. .. .. .. .. ..- attr(*, "order")= int 1
.. .. .. .. .. ..- attr(*, "intercept")= int 1
.. .. .. .. .. ..- attr(*, "response")= int 0
.. .. .. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. .. .. .. .. ..- attr(*, "predvars")= language list(duree)
.. .. .. .. .. ..- attr(*, "dataClasses")= Named chr "numeric"
.. .. .. .. .. .. ..- attr(*, "names")= chr "duree"
.. .. ..@ block : Factor w/ 1 level "0": 1 1 1 1 1 1 1 1 1 1 ...
.. .. ..@ weights : num [1:972] 1 1 1 1 1 1 1 1 1 1 ...
..@ estimates : list()
..@ method : chr "Two-Sample Fisher-Pitman Permutation Test"
..@ call : language independence_test.IndependenceProblem(object = <S4 object of class structure("IndependenceProblem", package = "coin")>, teststat = "scalar", distribution = function (object) ...
And when I call One1@distribution@pvalue
i got a formula...
Thanks for your help!
Aucun commentaire:
Enregistrer un commentaire