R version 4.4.0 RC (2024-04-16 r86451 ucrt) -- "Puppy Cup" 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( "censReg" ) Loading required package: maxLik Loading required package: miscTools Please cite the 'maxLik' package as: Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1. If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site: https://r-forge.r-project.org/projects/maxlik/ Please cite the 'censReg' package as: Henningsen, Arne (2017). censReg: Censored Regression (Tobit) Models. R package version 0.5. http://CRAN.R-Project.org/package=censReg. If you have questions, suggestions, or comments regarding the 'censReg' package, please use a forum or 'tracker' at the R-Forge site of the 'sampleSelection' project: https://r-forge.r-project.org/projects/sampleselection/ > library( "plm" ) > > options( digits = 5 ) > > nId <- 100 > nTime <- 3 > > set.seed( 123 ) > pData <- data.frame( + id = rep( paste( "F", 1:nId, sep = "_" ), each = nTime ), + time = rep( 1980 + 1:nTime, nId ) ) > pData$ui <- rep( rnorm( nId ), each = nTime ) > pData$x1 <- rnorm( nId * nTime ) > pData$x2 <- runif( nId * nTime ) > pData$ys <- -1 + pData$ui + 2 * pData$x1 + 3 * pData$x2 + rnorm( nId * nTime ) > pData$y <- ifelse( pData$ys > 0, pData$ys, 0 ) > pData <- pdata.frame( pData, c( "id", "time" ), stringsAsFactors = FALSE ) > > > # ## Newton-Raphson method > # randEff <- censReg( y ~ x1 + x2, data = pData ) > # maxLik:::summary.maxLik( randEff ) > > ## BHHH method > randEffBhhh <- censReg( y ~ x1 + x2, data = pData, method = "BHHH" ) > print( maxLik:::summary.maxLik( randEffBhhh ), digits = 2 ) -------------------------------------------- Maximum Likelihood estimation BHHH maximisation, 11 iterations Return code 8: successive function values within relative tolerance limit (reltol) Log-Likelihood: -330.52 5 free parameters Estimates: Estimate Std. error t value Pr(> t) (Intercept) -1.087 0.235 -4.6 4e-06 *** x1 2.069 0.092 22.4 <2e-16 *** x2 3.115 0.370 8.4 <2e-16 *** logSigmaMu -0.106 0.129 -0.8 0.4 logSigmaNu 0.026 0.065 0.4 0.7 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 -------------------------------------------- > > ## BFGS method (optim) > randEffBfgs <- censReg( y ~ x1 + x2, data = pData, method = "BFGS" ) > print( maxLik:::summary.maxLik( randEffBfgs ), digits = 2 ) -------------------------------------------- Maximum Likelihood estimation BFGS maximization, 29 iterations Return code 0: successful convergence Log-Likelihood: -330.52 5 free parameters Estimates: Estimate Std. error t value Pr(> t) (Intercept) -1.087 0.226 -4.8 2e-06 *** x1 2.070 0.097 21.4 <2e-16 *** x2 3.115 0.327 9.5 <2e-16 *** logSigmaMu -0.106 0.131 -0.8 0.4 logSigmaNu 0.026 0.070 0.4 0.7 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 -------------------------------------------- > > ## BFGS method (R) > randEffBfgsr <- censReg( y ~ x1 + x2, data = pData, method = "BFGSR" ) > print( maxLik:::summary.maxLik( randEffBfgsr ), digits = 2 ) -------------------------------------------- Maximum Likelihood estimation BFGSR maximization, 22 iterations Return code 2: successive function values within tolerance limit (tol) Log-Likelihood: -330.52 5 free parameters Estimates: Estimate Std. error t value Pr(> t) (Intercept) -1.086 0.226 -4.8 2e-06 *** x1 2.070 0.097 21.4 <2e-16 *** x2 3.115 0.327 9.5 <2e-16 *** logSigmaMu -0.106 0.131 -0.8 0.4 logSigmaNu 0.026 0.070 0.4 0.7 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 -------------------------------------------- > > > proc.time() user system elapsed 1.43 0.18 1.62