Skip to content

Commit

Permalink
1.8-5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderrobitzsch committed Feb 28, 2023
1 parent aca772f commit 6f70f30
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 26 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: mdmb
Type: Package
Title: Model Based Treatment of Missing Data
Version: 1.8-1
Date: 2023-02-17 22:38:37
Version: 1.8-5
Date: 2023-02-28 14:57:46
Author:
Alexander Robitzsch [aut, cre], Oliver Luedtke [aut]
Maintainer:
Expand Down
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## File Name: RcppExports.R
## File Version: 1.008001
## File Version: 1.008005
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

Expand Down
2 changes: 1 addition & 1 deletion R/frm_em.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## File Name: frm_em.R
## File Version: 0.961
## File Version: 0.966


frm_em <- function(dat, dep, ind, weights=NULL, verbose=TRUE,
Expand Down
8 changes: 6 additions & 2 deletions R/frm_em_calc_likelihood.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## File Name: frm_em_calc_likelihood.R
## File Version: 1.387
## File Version: 1.397

#--- loop over models and predictions
frm_em_calc_likelihood <- function( dat, ind0, NM, eps=1E-30, iter=NULL,
Expand Down Expand Up @@ -78,9 +78,13 @@ frm_em_calc_likelihood <- function( dat, ind0, NM, eps=1E-30, iter=NULL,

post <- frm_normalize_posterior( post=post, case=dat$case)
dat$weights <- dat$weights0 * post

#--- compute total log likelihood
ll <- frm_em_calc_total_likelihood(dat=dat, weights0=weights0,
like_obs=like_obs, post_miss=post_miss)
like_obs=like_obs, post_miss=post_miss, like=like)


#--- output
res <- list( loglike=loglike, post=post, coefs=coefs,
model_results=model_results, ll=ll, post0=post0,
ind0=ind0, like=like, like0=like0 )
Expand Down
25 changes: 20 additions & 5 deletions R/frm_em_calc_total_likelihood.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
## File Name: frm_em_calc_total_likelihood.R
## File Version: 0.08
## File Version: 0.123

frm_em_calc_total_likelihood <- function(dat, weights0,
like_obs, post_miss)
like_obs, post_miss, like=NULL)
{
eps <- 1E-50

# calculate total likelihood per case
like_case <- like_obs * post_miss
like_case <- rowsum( like_case, dat$case )[,1]
ll <- sum( log( like_case + eps ) * weights0 )
# like_case <- like_obs * post_miss
# like_case <- rowsum( like_case, dat$case )[,1]

#--- original computation
# like_case <- like_obs * post_miss
# like_case <- rowsum( like_case, dat$case )[,1]
# ll <- sum( log( like_case + eps ) * weights0 )

if (is.null(like)){
like_case <- like_obs * post_miss
like_case <- rowsum( like_case, dat$case )[,1]
ll <- sum( log( like_case + eps ) * weights0 )
} else {
like_case <- like * dat$delta_nodes
like_case <- rowsum( like_case, dat$case )[,1]
ll <- sum( log( like_case + eps ) * weights0 )
}
return(ll)
}
4 changes: 3 additions & 1 deletion R/frm_prepare_data_em.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## File Name: frm_prepare_data_em.R
## File Version: 0.295
## File Version: 0.303

frm_prepare_data_em <- function(dat, dep, ind, weights0, dat0, update_model=NULL)
{
Expand All @@ -9,6 +9,7 @@ frm_prepare_data_em <- function(dat, dep, ind, weights0, dat0, update_model=NULL
dat$weights0 <- weights0
dat$weights <- 1
dat$resp_all <- 1
dat$delta_nodes <- 1
# vector of dependent variables
dv_vars <- c()
for (mm in 1:NM){
Expand All @@ -20,6 +21,7 @@ frm_prepare_data_em <- function(dat, dep, ind, weights0, dat0, update_model=NULL
dat <- frm_prepare_data_include_latent_data( dat=dat, var_mm=var_mm,
nodes_mm=nodes_mm, ind_mm=ind[[mm]] )
}

#** prepare dependent variables
dat <- frm_prepare_data_include_latent_data( dat=dat,
var_mm=dep$dv_vars, nodes_mm=dep$nodes, ind_mm=dep )
Expand Down
10 changes: 9 additions & 1 deletion R/frm_prepare_data_include_latent_data.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## File Name: frm_prepare_data_include_latent_data.R
## File Version: 0.21
## File Version: 0.224


##################################################################
Expand Down Expand Up @@ -30,6 +30,14 @@ frm_prepare_data_include_latent_data <- function( dat, var_mm,
dat11 <- dat0[ rep_ind, ]
dat11[,var_mm] <- rep( nodes_mm, each=N0 )
dat11$weights <- dat11$weights * rep( ind_mm$nodes_weights, each=N0 )
#*** include delta_nodes for some models
model_mm <- ind_mm$model
models0 <- c("linreg", "yjtreg", "bctreg")
if (sum( model_mm %in% models0 )> 0 ){
d1 <- cbind( c( diff(nodes_mm), NA), c(NA, diff(nodes_mm) ) )
diff_nodes <- rowMeans(d1, na.rm=TRUE)
dat11$delta_nodes <- dat11$delta_nodes * rep( diff_nodes, each=N0 )
}
dat12 <- rbind( dat12, dat11 )
}
dat12 <- dat12[ order(dat12$case), ]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
If you use `mdmb` and have suggestions for improvement or have found bugs, please email me at robitzsch@leibniz-ipn.de.
Please always provide a minimal dataset, necessary to demonstrate the problem,
a minimal runnable code necessary to reproduce the issue, which can be run on the given dataset, and
all necessary information on the used librarys, the R version, and the OS it is run on, perhaps a sessionInfo().
all necessary information on the used librarys, the R version, and the OS it is run on, perhaps a `sessionInfo()`.

#### Manual

Expand All @@ -25,9 +25,9 @@ The CRAN version can be installed from within R using:
utils::install.packages("mdmb")
```

#### GitHub version `mdmb` 1.8-1 (2023-02-17)
#### GitHub version `mdmb` 1.8-5 (2023-02-28)

[![](https://img.shields.io/badge/github%20version-1.8--1-orange.svg)](https://github.com/alexanderrobitzsch/mdmb)&#160;&#160;
[![](https://img.shields.io/badge/github%20version-1.8--5-orange.svg)](https://github.com/alexanderrobitzsch/mdmb)&#160;&#160;

The version hosted [here](https://github.com/alexanderrobitzsch/mdmb) is the development version of `mdmb`.
The GitHub version can be installed using `devtools` as:
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pandoc: 1.13.1
pkgdown: 1.5.1
pkgdown_sha: ~
articles: []
last_built: 2023-02-17T21:45Z
last_built: 2023-02-28T14:03Z

6 changes: 4 additions & 2 deletions inst/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ CHANGELOG mdmb


---------------------------------------------------------------------
VERSIONS mdmb 1.8 | 2023-02-17 | Last: mdmb 1.8-1
VERSIONS mdmb 1.8 | 2023-02-28 | Last: mdmb 1.8-5
---------------------------------------------------------------------

xxxx *
FIXED * now ouput observed log-likelihood value and not expected
log-likelihood (thanks to Paul Allison)



DATA * included/modified datasets: ---
Expand Down
2 changes: 1 addition & 1 deletion src/RcppExports.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//// File Name: RcppExports.cpp
//// File Version: 1.008001
//// File Version: 1.008005
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

Expand Down

0 comments on commit 6f70f30

Please sign in to comment.