Package 'ProfileLikelihood'

Title: Profile Likelihood for a Parameter in Commonly Used Statistical Models
Description: Provides profile likelihoods for a parameter of interest in commonly used statistical models. The models include linear models, generalized linear models, proportional odds models, linear mixed-effects models, and linear models for longitudinal responses fitted by generalized least squares. The package also provides plots for normalized profile likelihoods as well as the maximum profile likelihood estimates and the kth likelihood support intervals.
Authors: Leena Choi [aut, cre]
Maintainer: Leena Choi <[email protected]>
License: GPL (>= 3)
Version: 1.3
Built: 2025-02-15 04:09:09 UTC
Source: https://github.com/choileena/profilelikelihood

Help Index


Profile Likelihood for a Parameter in Commonly Used Statistical Models

Description

This package provides profile likelihoods for a parameter of interest in commonly used statistical models. The models include linear models, generalized linear models, proportional odds models, linear mixed-effects models, and linear models for longitudinal responses fitted by generalized least squares. The package also provides plots for normalized profile likelihoods as well as the maximum profile likelihood estimates and the kth likelihood support intervals (Royall, 1997).

Details

Use profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls and profilelike.lme to obtain profile likelihoods and normalized profile likelihoods, and plot the normalized profile likelihoods using profilelike.plot. Use profilelike.summary to obtain the maximum profile likelihood estimate and the kth likelihood support intervals.

Author(s)

Leena Choi <[email protected]>

Maintainer: Leena Choi <[email protected]>

References

Royall, Richard M. (1997). Statistical Evidence: A Likelihood Paradiam. Chapman & Hall/CRC.

Pawitan, Yudi (2001). In All Likelihood: Statistical Modelling and Inference Using Likelihood. Oxford University Press.

See Also

profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls, profilelike.lme, profilelike.plot, profilelike.summary

Examples

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- c(rep(0,10), rep(1,10))
weight <- c(ctl, trt)
dd <- data.frame(group=group, weight=weight)
xx <- profilelike.lm(formula = weight ~ 1, data=dd, profile.theta="group",
				lo.theta=-2, hi.theta=1, length=500)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)

Example Data for a Profile Likelihood in Generalized Linear Models

Description

This data is used to illustrate how to obtain values for a profile likelihood of a parameter of interest in a generalized linear model.

Usage

data(dataglm)

Format

A data frame with 100 observations on the following 5 variables.

id

a numeric vector; unique identification number

y

a numeric vector; binary outcome variable

x1

a numeric vector; covariate

x2

a numeric vector; covariate

group

a numeric vector; covariate and a parameter of interest

Details

This data is used to illustrate how to obtain values for a profile likelihood of a parameter of interest in a logistic regression model. A parameter of interest is group indicator variable, y is a binary outcome, and x1 and x2 are covariates in a logistic regression model.

Examples

data(dataglm)
xx <- profilelike.glm(y ~ x1 + x2, data=dataglm, profile.theta="group", 
				family=binomial(link="logit"), length=500, round=2)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)

Example Data for a Profile Likelihood in Proportional Odds Models

Description

This data is used to illustrate how to obtain values for a profile likelihood of a parameter of interest in a proportional odds model.

Usage

data(datapolr)

Format

A data frame with 66 observations on the following 5 variables.

id

a numeric vector; unique identification number

y

a numeric vector; ordinal outcome variable; should be defined as a factor

x1

a numeric vector; covariate

x2

a numeric vector; covariate

group

a numeric vector; covariate and a parameter of interest

Details

This data is used to illustrate how to obtain values for a profile likelihood of a parameter of interest in a proportional odds model. A parameter of interest is group indicator variable, y is an ordinal outcome, and x1 and x2 are covariates in a proportional odds model.

Examples

data(datapolr)
datapolr$y <- as.factor(datapolr$y)
xx <- profilelike.polr(y ~ x1 + x2, data=datapolr, profile.theta="group", 
				method="logistic", lo.theta=-2, hi.theta=2.5, length=500)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)

P-values based on LR statistics for 2 x 2 Tables

Description

This function provides p-values based on likelihood ratio (LR) statistics for 2 x 2 tables.

Usage

LR.pvalue(y1, y2, n1, n2, interval=0.01)

Arguments

y1

the number of success for treatment 1.

y2

the number of success for treatment 2.

n1

the sample size for treatment 1.

n2

the sample size for treatment 2.

interval

grid for evaluating a parameter of interest to obtain values for likelihoods. The default is 0.01.

Details

This function provides p-values based on the profile and conditional likelihood ratio (LR) statistics for 2 x 2 tables. The function also provides the profile and conditional likelihood support intervals (k=6.8) corresponding to a 95% confidence interval based on a normal approximation. For comparison purpose, p-values from Pearson's Chi-squared test, Fisher's exact test and Pearson's Chi-squared test with continuity correction are also provided.

Value

mle.lor.uncond

the maximum likelihood estimate for log odds ratio.

mle.lor.cond

the maximum conditional likelihood estimate for log odds ratio.

LI.norm.profile

profile likelihood support interval (k=6.8) corresponding to a 95% confidence interval based on a normal approximation.

LI.norm.cond

conditional likelihood support interval (k=6.8) corresponding to a 95% confidence interval based on a normal approximation.

LR.profile

profile likelihood ratio.

LR.cond

conditional likelihood ratio.

Pvalue.LR.profile

p-value based on the profile LR statistic.

Pvalue.LR.cond

p-value based on the conditional LR statistic.

Pvalue.chisq.test

p-value from Pearson's Chi-squared test.

Pvalue.fisher.test

p-value from Fisher's exact test.

Pvalue.chisq.cont.correction

p-value from Pearson's Chi-squared test with continuity correction.

Warning

Likelihood intervals, LRs and the corresonding p-values are not reliable with empty cells (y1=0 or y2=0) in 2 x 2 tables.

P-values from Pearson's Chi-squared test, Fisher's exact test and Pearson's Chi-squared test with continuity correction are provided only for comparison purpose. For more options, use chisq.test and fisher.test for these tests.

Author(s)

Leena Choi <[email protected]>

See Also

profilelike.plot, profilelike.summary, profilelike.glm

Examples

(fit <- LR.pvalue(y1=20, y2=30, n1=50, n2=50, interval=0.01))

Profile Likelihood for Generalized Linear Models

Description

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a generalized linear model.

Usage

profilelike.glm(formula, data, profile.theta, family = stats::gaussian, 
	offset.glm = NULL, lo.theta = NULL, hi.theta = NULL, length = 300, 
	round = 2, subset = NULL, weights = NULL, offset = NULL, ...)

Arguments

formula

see corresponding documentation in glm.

data

a data frame. See corresponding documentation in glm.

profile.theta

a parameter of interest, theta; must be a numeric variable.

family

see corresponding documentation in glm.

offset.glm

same usage as offset in glm. See corresponding documentation for offset in glm.

lo.theta

lower bound for a parameter of interest to obtain values for a profile likelihood.

hi.theta

upper bound for a parameter of interest to obtain values for a profile likelihood.

length

length of numerical grid values for a parameter of interest to obtain values for a profile likelihood.

round

the number of decimal places for round function to automatically define lower and upper bounds of numerical grid for a parameter of interest. If an automatically defined parameter range is not appropriate, increase the number or specify lo.theta and hi.theta.

subset

should not be provided.

weights

should not be provided.

offset

should not be provided. Instead use offset.glm.

...

further arguments passed to or from other methods.

Details

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a generalized linear model. Users must define a parameter of interest in a generalized linear model. This function can be used for generalized linear models comparable with the glm function. However, arguments weights, subset, and offset should not be provided. An argument offset in glm function can be provided using offset.glm. A normalized profile likelihood is obtained by a profile likelihood being divided by the maximum value of the profile likelihood so that a normalized profile likelihood ranges from 0 to 1.

Value

theta

numerical grid values for a parameter of interest in a specified range (between lower and upper bounds).

profile.lik

numerical values for a profile likelihood corresponding to theta in a specified range (between lower and upper bounds).

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

Warning

Arguments weights, subset, and offset in the glm function are not comparable.

Missing values should be removed.

Author(s)

Leena Choi <[email protected]>

See Also

profilelike.plot, profilelike.summary, profilelike.lm, profilelike.polr, profilelike.gls, profilelike.lme, glm

Examples

data(dataglm)
xx <- profilelike.glm(y ~ x1 + x2, data=dataglm, profile.theta="group", 
				family=binomial(link="logit"), length=500, round=2)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)

Profile Likelihood for Linear Models for Longitudinal Responses Fitted by Generalized Least Squares

Description

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a linear model for longitudinal responses fitted by generalized least squares.

Usage

profilelike.gls(formula, data, correlation = NULL, subject, profile.theta, 
		method = "ML", lo.theta, hi.theta, length = 300, round = 2, 
		subset = NULL, weights = NULL, ...)

Arguments

formula

see corresponding documentation in gls.

data

a data frame. See corresponding documentation in gls.

correlation

see corresponding documentation in gls.

subject

see corresponding documentation in gls.

profile.theta

a parameter of interest, theta; must be a numeric variable.

method

see corresponding documentation in gls.

lo.theta

lower bound for a parameter of interest to obtain values for a profile likelihood.

hi.theta

upper bound for a parameter of interest to obtain values for a profile likelihood.

length

length of numerical grid values for a parameter of interest to obtain values for a profile likelihood.

round

the number of decimal places for round function to automatically define lower and upper bounds of numerical grid for a parameter of interest. If an automatically defined parameter range is not appropriate, increase the number or specify lo.theta and hi.theta.

subset

should not be provided.

weights

should not be provided.

...

further arguments passed to or from other methods.

Details

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a linear model for longitudinal responses fitted by generalized least squares. Users must define a parameter of interest in the model. This function can be used for models for longitudinal responses comparable with the gls function. However, arguments weights and subset should not be provided. A normalized profile likelihood is obtained by a profile likelihood being divided by the maximum value of the profile likelihood so that a normalized profile likelihood ranges from 0 to 1.

Value

theta

numerical grid values for a parameter of interest in a specified range (between lower and upper bounds).

profile.lik

numerical values for a profile likelihood corresponding to theta in a specified range (between lower and upper bounds).

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

Warning

Arguments weights and subset in the gls function are not comparable.

Missing values should be removed.

Author(s)

Leena Choi <[email protected]>

See Also

profilelike.plot, profilelike.summary, profilelike.lm, profilelike.glm, profilelike.polr, profilelike.lme, gls

Examples

data(Gasoline, package = "nlme")
xx <- profilelike.gls(formula=yield ~ endpoint, correlation=nlme::corAR1(form = ~ 1 | id),
	data=Gasoline, subject="Sample", profile.theta="vapor", method="ML", 
	lo.theta=1, hi.theta=5, length=500, round=2)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=4)

Profile Likelihood for Linear Models

Description

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a linear model.

Usage

profilelike.lm(formula, data, profile.theta, lo.theta = NULL, hi.theta = NULL, 
	length = 300, round = 2, subset = NULL, weights = NULL, offset = NULL, ...)

Arguments

formula

see corresponding documentation in lm.

data

a data frame. See corresponding documentation in lm.

profile.theta

a parameter of interest, theta; must be a numeric variable.

lo.theta

lower bound for a parameter of interest to obtain values for a profile likelihood.

hi.theta

upper bound for a parameter of interest to obtain values for a profile likelihood.

length

length of numerical grid values for a parameter of interest to obtain values for a profile likelihood.

round

the number of decimal places for round function to automatically define lower and upper bounds of numerical grid for a parameter of interest. If an automatically defined parameter range is not appropriate, increase the number or specify lo.theta and hi.theta.

subset

should not be provided.

weights

should not be provided.

offset

should not be provided.

...

further arguments passed to or from other methods.

Details

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a linear model. Users must define a parameter of interest in a linear model. This function can be used for linear models comparable with the lm function. However, arguments weights, subset, and offset should not be provided. A normalized profile likelihood is obtained by a profile likelihood being divided by the maximum value of the profile likelihood so that a normalized profile likelihood ranges from 0 to 1.

Value

theta

numerical grid values for a parameter of interest in a specified range (between lower and upper bounds).

profile.lik

numerical values for a profile likelihood corresponding to theta in a specified range (between lower and upper bounds).

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

Warning

Arguments weights, subset, and offset in the lm function are not comparable.

Missing values should be removed.

Author(s)

Leena Choi <[email protected]>

See Also

profilelike.plot, profilelike.summary, profilelike.glm, profilelike.polr, profilelike.gls, profilelike.lme, lm

Examples

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- c(rep(0,10), rep(1,10))
weight <- c(ctl, trt)
dd <- data.frame(group=group, weight=weight)
xx <- profilelike.lm(formula = weight ~ 1, data=dd, profile.theta="group",
			lo.theta=-2, hi.theta=1, length=500)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)

Profile Likelihood for Linear Mixed-Effects Models

Description

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a linear mixed-effects model.

Usage

profilelike.lme(formula, data, subject, random, correlation = NULL, 
	profile.theta, method = "ML", lo.theta, hi.theta, length = 300, 
	round = 2, subset = NULL, weights = NULL, ...)

Arguments

formula

see corresponding documentation in lme.

data

a data frame. See corresponding documentation in lme.

subject

see corresponding documentation in lme.

random

see corresponding documentation in lme.

correlation

see corresponding documentation in lme.

profile.theta

a parameter of interest, theta; must be a numeric variable.

method

see corresponding documentation in lme.

lo.theta

lower bound for a parameter of interest to obtain values for a profile likelihood.

hi.theta

upper bound for a parameter of interest to obtain values for a profile likelihood.

length

length of numerical grid values for a parameter of interest to obtain values for a profile likelihood.

round

the number of decimal places for round function to automatically define lower and upper bounds of numerical grid for a parameter of interest. If an automatically defined parameter range is not appropriate, increase the number or specify lo.theta and hi.theta.

subset

should not be provided.

weights

should not be provided.

...

further arguments passed to or from other methods.

Details

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a linear mixed-effects model. Users must define a parameter of interest in a linear mixed-effects model. This function can be used for models comparable with the lme function. However, arguments weights and subset should not be provided. A normalized profile likelihood is obtained by a profile likelihood being divided by the maximum value of the profile likelihood so that a normalized profile likelihood ranges from 0 to 1.

Value

theta

numerical grid values for a parameter of interest in a specified range (between lower and upper bounds).

profile.lik

numerical values for a profile likelihood corresponding to theta in a specified range (between lower and upper bounds).

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

Warning

Arguments weights and subset in the lme function are not comparable.

Missing values should be removed.

Author(s)

Leena Choi <[email protected]>

See Also

profilelike.plot, profilelike.summary, profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls, lme

Examples

## Not run: 
xx <- profilelike.lme(formula = yield ~ endpoint, random = ~ 1 | id, 
		correlation=corAR1(form = ~ 1 | id), data=Gasoline, subject="Sample", 
		profile.theta="vapor", method="ML", lo.theta=1, hi.theta=5, length=500, round=2)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=4)

## End(Not run)

Profile Likelihood Plot

Description

The function provides a plot for a normalized profile likelihood as well as the maximum profile likelihood estimate and the kth likelihood support intervals (Royall, 1997).

Usage

profilelike.plot(theta = theta, profile.lik.norm = profile.lik.norm, round = 2)

Arguments

theta

numerical grid values for a parameter of interest in a specified range.

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

round

the number of decimal places for round function for presentation of the maximum profile likelihood estimate and the kth likelihood support intervals.

Details

The function provides a plot for a normalized profile likelihood obtained from profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls and profilelike.lme. The maximum profile likelihood estimate, the kth likelihood support interval (k=8, k=20, and k=32), and the likelihood support interval (k=6.8) corresponding to a 95% confidence interval based on a normal approximation are also presented.

Value

A normalized profile likelihood plot with the maximum profile likelihood estimate and the kth likelihood support intervals.

Author(s)

Leena Choi <[email protected]>

References

Royall, Richard M. (1997). Statistical Evidence: A Likelihood Paradiam. Chapman & Hall/CRC.

Pawitan, Yudi (2001). In All Likelihood: Statistical Modelling and Inference Using Likelihood. Oxford University Press.

See Also

profilelike.summary, profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls, profilelike.lme

Examples

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- c(rep(0,10), rep(1,10))
weight <- c(ctl, trt)
dd <- data.frame(group=group, weight=weight)
xx <- profilelike.lm(formula = weight ~ 1, data=dd, profile.theta="group",
			lo.theta=-2, hi.theta=1, length=500)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)
profilelike.summary(k=8, theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=3)

Profile Likelihood for Proportional Odds Models

Description

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a proportional odds model.

Usage

profilelike.polr(formula, data, profile.theta, method = "logistic", 
	lo.theta = NULL, hi.theta = NULL, length = 300, round = 2, 
	subset = NULL, weights = NULL, offset = NULL, ...)

Arguments

formula

see corresponding documentation in polr.

data

a data frame. See corresponding documentation in polr.

profile.theta

a parameter of interest, theta; must be a numeric variable.

method

see corresponding documentation in polr.

lo.theta

lower bound for a parameter of interest to obtain values for a profile likelihood.

hi.theta

upper bound for a parameter of interest to obtain values for a profile likelihood.

length

length of numerical grid values for a parameter of interest to obtain values for a profile likelihood.

round

the number of decimal places for round function to automatically define lower and upper bounds of numerical grid for a parameter of interest. If an automatically defined parameter range is not appropriate, increase the number or specify lo.theta and hi.theta.

subset

should not be provided.

weights

should not be provided.

offset

should not be provided.

...

further arguments passed to or from other methods.

Details

This function provides values for a profile likelihood and a normalized profile likelihood for a parameter of interest in a proportional odds model. Users must define a parameter of interest in a proportional odds model. This function can be used for proportional odds models comparable with the polr function. However, arguments weights, subset, and offset should not be provided. A normalized profile likelihood is obtained by a profile likelihood being divided by the maximum value of the profile likelihood so that a normalized profile likelihood ranges from 0 to 1.

Value

theta

numerical grid values for a parameter of interest in a specified range (between lower and upper bounds).

profile.lik

numerical values for a profile likelihood corresponding to theta in a specified range (between lower and upper bounds).

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

Warning

Arguments weights, subset, and offset in the polr function are not comparable.

Missing values should be removed.

Author(s)

Leena Choi <[email protected]>

See Also

profilelike.plot, profilelike.summary, profilelike.lm, profilelike.glm, profilelike.gls, profilelike.lme, polr

Examples

data(datapolr)
datapolr$y <- as.factor(datapolr$y)
xx <- profilelike.polr(y ~ x1 + x2, data=datapolr, profile.theta="group", 
				method="logistic", lo.theta=-2, hi.theta=2.5, length=500)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)

Summary for the Maximum Profile Likelihood Estimate and Likelihood Support Intervals

Description

The function provides the maximum profile likelihood estimate and likelihood support intervals (Royall, 1997).

Usage

profilelike.summary(k, theta = theta, profile.lik.norm = profile.lik.norm, 
		round = 2)

Arguments

k

strength of evidence for the kth likelihood support interval.

theta

numerical grid values for a parameter of interest in a specified range.

profile.lik.norm

numerical values for a normalized profile likelihood ranging from 0 to 1.

round

the number of decimal places for round function for presentation of the maximum profile likelihood estimate and the kth likelihood support intervals.

Details

The function provides the maximum profile likelihood estimate and likelihood support intervals for a profile likelihood obtained from profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls and profilelike.lme. The kth likelihood support interval and the likelihood support interval (k=6.8) corresponding to a 95% confidence interval based on a normal approximation are provided.

Value

k

strength of evidence for the kth likelihood support interval.

mle

the maximum profile likelihood estimate.

LI.k

the kth likelihood support interval.

LI.norm

likelihood support interval (k=6.8) corresponding to a 95% confidence interval based on a normal approximation.

Author(s)

Leena Choi <[email protected]>

References

Royall, Richard M. (1997). Statistical Evidence: A Likelihood Paradiam. Chapman & Hall/CRC.

Pawitan, Yudi (2001). In All Likelihood: Statistical Modelling and Inference Using Likelihood. Oxford University Press.

See Also

profilelike.plot, profilelike.lm, profilelike.glm, profilelike.polr, profilelike.gls, profilelike.lme

Examples

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- c(rep(0,10), rep(1,10))
weight <- c(ctl, trt)
dd <- data.frame(group=group, weight=weight)
xx <- profilelike.lm(formula = weight ~ 1, data=dd, profile.theta="group",
				lo.theta=-2, hi.theta=1, length=500)
profilelike.plot(theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=2)
profilelike.summary(k=8, theta=xx$theta, profile.lik.norm=xx$profile.lik.norm, round=3)