R Under development (unstable) (2024-03-07 r86063 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(survey) Loading required package: grid Loading required package: Matrix Loading required package: survival Attaching package: 'survey' The following object is masked from 'package:graphics': dotchart > > ################################################################################ > # Example from svyolr: runs OK > data(api) > dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) > dclus1<-update(dclus1, mealcat=cut(meals,c(0,25,50,75,100))) > > m<-svyolr(mealcat~avg.ed+mobility+stype, design=dclus1) > m Call: svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1) Coefficients: avg.ed mobility stypeH stypeM -2.6999217 0.0325042 -1.7574715 -0.6191463 Intercepts: (0,25]|(25,50] (25,50]|(50,75] (50,75]|(75,100] -8.857919 -6.586464 -4.924938 > > ## Use regTermTest for testing multiple parameters > test<-regTermTest(m, ~avg.ed+stype, method="LRT") > ################################################################################ > > ################################################################################ > # If we wrap everything into a function: error b/c it looks for design variable > # dclus1 in .GlobalEnv > > foo <- function(x){ + dclus1<-svydesign(id=~dnum, weights=~pw, data=x, fpc=~fpc) + dclus1<-update(dclus1, mealcat=cut(meals,c(0,25,50,75,100))) + + m<-svyolr(mealcat~avg.ed+mobility+stype, design=dclus1) + ## Use regTermTest for testing multiple parameters + regTermTest(m, ~avg.ed+stype, method="LRT") + } > > # OK > foo(apiclus1) Working (Rao-Scott+F) LRT for avg.ed stype in svyolr(formula = mealcat ~ avg.ed + mobility + stype, design = dclus1) Working 2logLR = 0.6580304 p= 0.73257 (scale factors: 2.7 0.22 0.11 ); denominator df= 10 > > # Clean-up everything but apiclus1 and foo > rm(list = setdiff(ls(),c('apiclus1','foo','test'))) > > # Error > test2<-foo(apiclus1) > ################################################################################ > all.equal(test,test2) [1] TRUE > > > proc.time() user system elapsed 1.09 0.20 1.29