Learn R Programming

cmpp (version 0.0.1)

LogLike1: Compute the Log-Likelihood for the Model

Description

Computes the negative log-likelihood of the Cmpp model given parameters and the initialized data. The log-likelihood considers Gompertz distributions for competing risks.

Usage

LogLike1(param)

Value

A single numeric value representing the negative log-likelihood.

Arguments

param

A numeric vector of model parameters: alpha1, beta1, alpha2, beta2, where the first two are for the first event and the next two are for the second event.

Details

This function requires the data to be initialized using Initialize before being called. The log-likelihood is based on survival probabilities derived from the Gompertz distributions.

Examples

Run this code
library(cmpp)
data("fertility_data")
Nam <- names(fertility_data)
fertility_data$Education
datt <- make_Dummy(fertility_data, features = c("Education"))
datt <- datt$New_Data 
datt['Primary_Secondary'] <- datt$`Education:2`
datt['Higher_Education'] <- datt$`Education:3`
datt$`Education:2` <- datt$`Education:3` <- NULL
datt2 <- make_Dummy(datt, features = 'Event')$New_Data
d1 <- datt2$`Event:2`
d2 <- datt2$`Event:3`
feat <- datt2[c('age', 'Primary_Secondary', 'Higher_Education')] |> 
   data.matrix()
timee <- datt2[['time']]
Initialize(feat, timee, d1, d2, 1e-10)
param <- c(0.01, 0.01, 0.01, 0.01)
LogLike1(param)

Run the code above in your browser using DataLab