mbinreg {lazy.stat} | R Documentation |
Monotone Binary Regression
mbinreg(f, n, x = 1:length(f), method = 4, print = 0, plot = 0)
f |
vector of the frequency counts |
n |
vector of the # of trials |
x |
vector of the ordinal regressor variable |
method |
= 3 | 4 or "primary" | "secondary" or "continuous" | "discrete" |
print |
= 1 to print the result |
plot |
= 1 to plot the result |
This function finds phat which maximizes
log likelihood = f*log(phat) + (n-f)*log(1-phat)
subject to order(x) == order(phat)
The PAVA algorithm is ued.
The following code should produce the same result:
library(isotone)
res <- gpava( z=x, y=f/n, weights=n, ties=tie handling method )$x
de Leeuv, J., Hornik, K., and Mair, P. (2009) Isotone Optimization in R: Pool-Adjacent-Violators Algorithm (PAVA) and Active Set Methods. Journal of Statistical Software. Volume 32, Issue 5.
set.seed(1701) nobs <- 15 # x <- 1:nobs x <- floor(10*runif(nobs)) f <- round(10*runif(nobs)+1.5*x + 0.5) f[f<0] <- 1 n <- rep( max(f)+1, nobs ) n <- n-sample(-2:2, nobs, replace=1) f[f>=n]=n[f>=n]-1 f[f<0]=1 p0=f/n res <- mbinreg( f, n, x, print=1, plot=1 ) res <- mbinreg( f, n, x, print=1, plot=1, method="p" )