Package 'EMpeaksR'

Title: Conducting the Peak Fitting Based on the EM Algorithm
Description: The peak fitting of spectral data is performed by using the frame work of EM algorithm. We adapted the EM algorithm for the peak fitting of spectral data set by considering the weight of the intensity corresponding to the measurement energy steps (Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019, 2021 and 2023) <doi:10.1080/14686996.2019.1620123>, <doi:10.1080/27660400.2021.1899449> <doi:10.1080/27660400.2022.2159753>. The package efficiently estimates the parameters of Gaussian mixture model during iterative calculation between E-step and M-step, and the parameters are converged to a local optimal solution. This package can support the investigation of peak shift with two advantages: (1) a large amount of data can be processed at high speed; and (2) stable and automatic calculation can be easily performed.
Authors: Tarojiro Matsumura [aut, cre]
Maintainer: Tarojiro Matsumura <[email protected]>
License: MIT + file LICENSE
Version: 0.3.1
Built: 2024-10-31 16:33:22 UTC
Source: https://github.com/cran/EMpeaksR

Help Index


Visualization of the result of spect_em_dsgmm

Description

Visualization of the result of spect_em_dsgmm().

Usage

show_dsgmm_curve(spect_em_dsgmm_res,
                 x,
                 y,
                 mix_ratio_init,
                 mu_init,
                 sigma_init,
                 alpha_init,
                 eta_init)

Arguments

spect_em_dsgmm_res

data set obtained by spect_em_dsgmm()

x

measurement steps

y

intensity

mix_ratio_init

initial values of the mixture ratio of the components

mu_init

initial values of the mean of the components

sigma_init

initial values of the standard deviation of the components

alpha_init

initial values of the asymmetric parameter of the components

eta_init

initial values of the mixing ratio of Gauss and Lorentz distribution

Details

Perform a visualization of fitting curve estimated by Doniach-Sunjic-Gauss mixture model.

Value

Show the fitting curve and variation of the parameters.

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Examples

#generating the synthetic spectral data based on three component Doniach-Sunjic-Gauss mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(20, 50, 80)
true_sigma      <- c(3, 3, 3)
true_alpha      <- c(0.1, 0.3, 0.1)
true_eta        <- c(0.4, 0.6, 0.1)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

#trancated Doniach-Sunjic-Gauss
truncated_dsg <- function(x, mu, sigma, alpha, eta) {
                 ((eta*(((gamma(1-alpha)) /
                 ((x-mu)^2+(sqrt(2*log(2))*sigma)^2)^((1-alpha)/2)) *
                 cos((pi*alpha/2)+(1-alpha)*atan((x-mu) /
                 (sqrt(2*log(2))*sigma))))) + (1-eta)*dnorm(x, mu, sigma)) /
                 sum( ((eta*(((gamma(1-alpha)) /
                 ((x-mu)^2+(sqrt(2*log(2))*sigma)^2)^((1-alpha)/2)) *
                 cos((pi*alpha/2)+(1-alpha)*atan((x-mu) /
                 (sqrt(2*log(2))*sigma))))) + (1-eta)*dnorm(x, mu, sigma)))
}

y <- c(true_mix_ratio[1]*truncated_dsg(x = x,
                                       mu = true_mu[1],
                                       sigma = true_sigma[1],
                                       alpha = true_alpha[1],
                                       eta = true_eta[1])*10^degree +
       true_mix_ratio[2]*truncated_dsg(x = x,
                                       mu = true_mu[2],
                                       sigma = true_sigma[2],
                                       alpha = true_alpha[2],
                                       eta = true_eta[2])*10^degree +
       true_mix_ratio[3]*truncated_dsg(x = x,
                                       mu = true_mu[3],
                                       sigma = true_sigma[3],
                                       alpha = true_alpha[3],
                                       eta = true_eta[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3
mix_ratio_init <- c(0.2, 0.4, 0.4)
mu_init        <- c(20, 40, 70)
sigma_init     <- c(4, 3, 2)
alpha_init     <- c(0.3, 0.2, 0.4)
eta_init       <- c(0.5, 0.4, 0.3)

#Coducting calculation
SP_ECM_DSG_res <- spect_em_dsgmm(x = x,
                                 y = y,
                                 mu = mu_init,
                                 sigma = sigma_init,
                                 alpha = alpha_init,
                                 eta = eta_init,
                                 mix_ratio = mix_ratio_init,
                                 conv.cri = 1e-2,
                                 maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_dsgmm_curve(SP_ECM_DSG_res,
                 x,
                 y,
                 mix_ratio_init,
                 mu_init,
                 sigma_init,
                 alpha_init,
                 eta_init)

#Showing the result of spect_em_dsgmm()
print(cbind(c(mu_init),
            c(sigma_init),
            c(alpha_init),
            c(eta_init),
            c(mix_ratio_init)))

print(cbind(SP_ECM_DSG_res$mu,
            SP_ECM_DSG_res$sigma,
            SP_ECM_DSG_res$alpha,
            SP_ECM_DSG_res$eta,
            SP_ECM_DSG_res$mix_ratio))

print(cbind(true_mu,
            true_sigma,
            true_alpha,
            true_eta,
            true_mix_ratio))

Visualization of the result of spect_em_gmm

Description

Visualization of the result of spect_em_gmm().

Usage

show_gmm_curve(spect_em_gmm_res, x, y, mix_ratio_init, mu_init, sigma_init)

Arguments

spect_em_gmm_res

data set obtained by spect_em_gmm()

x

measurement steps

y

intensity

mix_ratio_init

initial values of the mixture ratio of the components

mu_init

initial values of the mean of the components

sigma_init

initial values of the standard deviation of the components

Details

Perform a visualization of fitting curve estimated by Gaussian mixture model.

Value

Show the fitting curve and variation of the parameters.

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Examples

#generating the synthetic spectral data based on three component Gausian mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(35, 50, 65)
true_sigma      <- c(3, 3, 3)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

y <- c(true_mix_ratio[1] * dnorm(x = x, mean = true_mu[1], sd = true_sigma[1])*10^degree +
       true_mix_ratio[2] * dnorm(x = x, mean = true_mu[2], sd = true_sigma[2])*10^degree +
       true_mix_ratio[3] * dnorm(x = x, mean = true_mu[3], sd = true_sigma[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3

mix_ratio_init  <- c(0.2, 0.4, 0.4)
mu_init         <- c(20, 40, 70)
sigma_init      <- c(2, 5, 4)

#Coducting calculation
SP_EM_G_res <- spect_em_gmm(x, y, mu = mu_init, sigma = sigma_init, mix_ratio = mix_ratio_init,
                            conv.cri = 1e-2, maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_gmm_curve(SP_EM_G_res, x, y, mix_ratio_init, mu_init, sigma_init)

#Showing the result of spect_em_gmm()
print(cbind(c(mu_init), c(sigma_init), c(mix_ratio_init)))
print(cbind(SP_EM_G_res$mu, SP_EM_G_res$sigma, SP_EM_G_res$mix_ratio))
print(cbind(true_mu, true_sigma, true_mix_ratio))

Visualization of the result of spect_em_lmm

Description

Visualization of the result of spect_em_lmm().

Usage

show_lmm_curve(spect_em_lmm_res, x, y, mix_ratio_init, mu_init, gam_init)

Arguments

spect_em_lmm_res

data set obtained by spect_em_lmm()

x

measurement steps

y

intensity

mix_ratio_init

initial values of the mixture ratio of the components

mu_init

initial values of the mean of the components

gam_init

initial values of the scale parameter of the components

Details

Perform a visualization of fitting curve estimated by Lorentz mixture model.

Value

Show the fitting curve and variation of the parameters.

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Examples

#generating the synthetic spectral data based on three component Lorentz mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(35, 50, 65)
true_gam        <- c(3, 3, 3)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

#Normalized Lorentz distribution
dCauchy <- function(x, mu, gam) {
    (dcauchy(x, mu, gam)) / sum(dcauchy(x, mu, gam))
  }

y <- c(true_mix_ratio[1] * dCauchy(x = x, mu = true_mu[1], gam = true_gam[1])*10^degree +
       true_mix_ratio[2] * dCauchy(x = x, mu = true_mu[2], gam = true_gam[2])*10^degree +
       true_mix_ratio[3] * dCauchy(x = x, mu = true_mu[3], gam = true_gam[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3

mix_ratio_init  <- c(0.2, 0.4, 0.4)
mu_init         <- c(20, 40, 70)
gam_init        <- c(2, 5, 4)

#Coducting calculation
SP_ECM_L_res <- spect_em_lmm(x, y, mu = mu_init, gam = gam_init, mix_ratio = mix_ratio_init,
                             conv.cri = 1e-2, maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_lmm_curve(SP_ECM_L_res, x, y, mix_ratio_init, mu_init, gam_init)

#Showing the result of spect_em_lmm()
print(cbind(c(mu_init), c(gam_init), c(mix_ratio_init)))
print(cbind(SP_ECM_L_res$mu, SP_ECM_L_res$gam, SP_ECM_L_res$mix_ratio))
print(cbind(true_mu, true_gam, true_mix_ratio))

Visualization of the result of spect_em_pvmm

Description

Visualization of the result of spect_em_pvmm().

Usage

show_pvmm_curve(spect_em_pvmm_res, x, y, mix_ratio_init, mu_init, sigma_init, eta_init)

Arguments

spect_em_pvmm_res

data set obtained by spect_em_pvmm()

x

measurement steps

y

intensity

mix_ratio_init

initial values of the mixture ratio of the components

mu_init

initial values of the mean of the components

sigma_init

initial values of the standard deviation of the components

eta_init

initial values of the mixing ratio of Gauss and Lorentz distribution

Details

Perform a visualization of fitting curve estimated by Pseudo-Voigt mixture model.

Value

Show the fitting curve and variation of the parameters.

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Examples

#generating the synthetic spectral data based on three component Pseudo-Voigt mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(35, 50, 65)
true_sigma      <- c(3, 3, 3)
true_eta        <- c(0.3, 0.8, 0.5)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

#Normalized Pseudo-Voigt distribution
  truncated_pv <- function(x, mu, sigma, eta) {
    (eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma)) /
      sum(eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma))
  }

y <- c(true_mix_ratio[1]*truncated_pv(x = x,
                                      mu = true_mu[1],
                                      sigma = true_sigma[1],
                                      eta = true_eta[1])*10^degree +
       true_mix_ratio[2]*truncated_pv(x = x,
                                      mu = true_mu[2],
                                      sigma = true_sigma[2],
                                      eta = true_eta[2])*10^degree +
       true_mix_ratio[3]*truncated_pv(x = x,
                                      mu = true_mu[3],
                                      sigma = true_sigma[3],
                                      eta = true_eta[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3

mix_ratio_init  <- c(0.2, 0.4, 0.4)
mu_init         <- c(20, 40, 70)
sigma_init      <- c(2, 5, 4)
eta_init        <- c(0.5, 0.4, 0.3)

#Coducting calculation
SP_ECM_PV_res <- spect_em_pvmm(x = x,
                               y = y,
                               mu = mu_init,
                               sigma = sigma_init,
                               eta = eta_init,
                               mix_ratio = mix_ratio_init,
                               conv.cri = 1e-2,
                               maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_pvmm_curve(SP_ECM_PV_res, x, y, mix_ratio_init, mu_init, sigma_init, eta_init)

#Showing the result of spect_em_pvmm()
print(cbind(c(mu_init), c(sigma_init), c(eta_init), c(mix_ratio_init)))
print(cbind(SP_ECM_PV_res$mu, SP_ECM_PV_res$sigma, SP_ECM_PV_res$eta, SP_ECM_PV_res$mix_ratio))
print(cbind(true_mu, true_sigma, true_eta, true_mix_ratio))

Visualization of the result of spect_em_pvmm_lback

Description

Visualization of the result of spect_em_pvmm_lback().

Usage

show_pvmm_lback_curve(spect_em_pvmm_lback_res,
                      x, y,
                      mix_ratio_init,
                      mu_init,
                      sigma_init,
                      eta_init,
                      x_lower,
                      x_upper)

Arguments

spect_em_pvmm_lback_res

data set obtained by spect_em_pvmm_lback()

x

measurement steps

y

intensity

mu_init

initial values of the mean of the components

sigma_init

initial values of the standard deviation of the components

eta_init

initial values of the mixing ratio of Gauss and Lorentz distribution

mix_ratio_init

initial values of the mixture ratio of the components

x_lower

lower limit of the measurement steps. Default is a minimum of x

x_upper

upper limit of the measurement steps. Default is a maximum of x

Details

Perform a visualization of fitting curve estimated by pseudo-Voigt mixture model with a linear background.

Value

Show the fitting curve and variation of the parameters.

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2023). High-throughput XPS spectrum modeling with autonomous background subtraction for 3 d 5/2 peak mapping of SnS. Science and Technology of Advanced Materials: Methods, 3(1), 2159753.

Examples

#generating the synthetic spectral data based on three component Pseudo-Voigt mixture model.
x              <- seq(0, 100, by = 0.5)
K              <- 3
true_mu        <- c(35, 50, 65)
true_sigma     <- c(3, 3, 3)
true_mix_ratio <- c(0.5/3, 0.5/3, 0.5/3, 0.5)
true_eta       <- c(0.4, 0.6, 0.1)
degree         <- 4

#Normalized Pseudo-Voigt distribution
  truncated_pv <- function(x, mu, sigma, eta) {
    (eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma)) /
      sum(eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma))
  }

y <- c(true_mix_ratio[1]*truncated_pv(x = x,
                                      mu = true_mu[1],
                                      sigma = true_sigma[1],
                                      eta = true_eta[1])*10^degree +
       true_mix_ratio[2]*truncated_pv(x = x,
                                      mu = true_mu[2],
                                      sigma = true_sigma[2],
                                      eta = true_eta[2])*10^degree +
       true_mix_ratio[3]*truncated_pv(x = x,
                                      mu = true_mu[3],
                                      sigma = true_sigma[3],
                                      eta = true_eta[3])*10^degree +
       true_mix_ratio[4]*(c(500*x + 15000) / sum(500*x + 15000))*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
mu_init        <- c(30, 40, 60)
sigma_init     <- c(4, 4, 4)
mix_ratio_init <- rep(1/(length(mu_init)+3), length(mu_init)+3)
eta_init       <- c(1, 1, 1)

#Coducting calculation
SP_ECM_PV_LBACK_res <- spect_em_pvmm_lback(x = x,
                                           y = y,
                                           mu = mu_init,
                                           sigma = sigma_init,
                                           eta = eta_init,
                                           mix_ratio = mix_ratio_init,
                                           x_lower = min(x),
                                           x_upper = max(x),
                                           conv.cri = 1e-2,
                                           maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_pvmm_lback_curve(spect_em_pvmm_lback_res = SP_ECM_PV_LBACK_res,
                      x = x,
                      y = y,
                      mix_ratio_init = mix_ratio_init,
                      mu_init = mu_init,
                      sigma_init = sigma_init,
                      eta_init = eta_init,
                      x_lower = min(x),
                      x_upper = max(x))


#Showing the result of spect_em_pvmm_lback()
print(cbind(SP_ECM_PV_LBACK_res$mu, SP_ECM_PV_LBACK_res$sigma, SP_ECM_PV_LBACK_res$eta,
            SP_ECM_PV_LBACK_res$mix_ratio[1:K]))

print(cbind(true_mu, true_sigma, true_eta, true_mix_ratio[1:K]))

Spectrum adapted ECM algorithm by DSGMM

Description

Perform a peak fitting based on the spectrum adapted ECM algorithm by Doniach-Sunjic-Gauss mixture model.

Usage

spect_em_dsgmm(x, y, mu, sigma, alpha, eta, mix_ratio, conv.cri, maxit)

Arguments

x

measurement steps

y

intensity

mu

mean of the components

sigma

standard deviation of the components

alpha

asymmetric parameter of the component

eta

mixing ratio of Gauss and Lorentz distribution

mix_ratio

mixture ratio of the components

conv.cri

criterion of the convergence

maxit

maximum number of the iteration

Details

Peak fitting is conducted by spectrum adapted ECM algorithm.

Value

mu

estimated mean of the components

sigma

estimated standard deviation of the components

alpha

estimated asymmetric parameter of the components

eta

estimated mixing ratio of Gauss and Lorentz distribution

mix_ratio

estimated mixture ratio of the components

it

number of the iteration to reach the convergence

LL

variation of the weighted log likelihood values

MU

variation of mu

SIGMA

variation of sigma

ALPHA

variation of alpha

ETA

variation of beta

MIX_RATIO

variation of mix_ratio

W_K

decomposed component of the spectral data

convergence

message for the convergence in the calculation

cal_time

calculation time to complete the peak fitting. Unit is seconds

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Examples

#generating the synthetic spectral data based on three component Doniach-Sunjic-Gauss mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(20, 50, 80)
true_sigma      <- c(3, 3, 3)
true_alpha      <- c(0.1, 0.3, 0.1)
true_eta        <- c(0.4, 0.6, 0.1)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

#trancated Doniach-Sunjic-Gauss
truncated_dsg <- function(x, mu, sigma, alpha, eta) {
                 ((eta*(((gamma(1-alpha)) /
                 ((x-mu)^2+(sqrt(2*log(2))*sigma)^2)^((1-alpha)/2)) *
                 cos((pi*alpha/2)+(1-alpha)*atan((x-mu) /
                 (sqrt(2*log(2))*sigma))))) + (1-eta)*dnorm(x, mu, sigma)) /
                 sum( ((eta*(((gamma(1-alpha)) /
                 ((x-mu)^2+(sqrt(2*log(2))*sigma)^2)^((1-alpha)/2)) *
                 cos((pi*alpha/2)+(1-alpha)*atan((x-mu) /
                 (sqrt(2*log(2))*sigma))))) + (1-eta)*dnorm(x, mu, sigma)))
}

y <- c(true_mix_ratio[1]*truncated_dsg(x = x,
                                       mu = true_mu[1],
                                       sigma = true_sigma[1],
                                       alpha = true_alpha[1],
                                       eta = true_eta[1])*10^degree +
       true_mix_ratio[2]*truncated_dsg(x = x,
                                       mu = true_mu[2],
                                       sigma = true_sigma[2],
                                       alpha = true_alpha[2],
                                       eta = true_eta[2])*10^degree +
       true_mix_ratio[3]*truncated_dsg(x = x,
                                       mu = true_mu[3],
                                       sigma = true_sigma[3],
                                       alpha = true_alpha[3],
                                       eta = true_eta[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3
mix_ratio_init <- c(0.2, 0.4, 0.4)
mu_init        <- c(20, 40, 70)
sigma_init     <- c(4, 3, 2)
alpha_init     <- c(0.3, 0.2, 0.4)
eta_init       <- c(0.5, 0.4, 0.3)

#Coducting calculation
SP_ECM_DSG_res <- spect_em_dsgmm(x = x,
                                 y = y,
                                 mu = mu_init,
                                 sigma = sigma_init,
                                 alpha = alpha_init,
                                 eta = eta_init,
                                 mix_ratio = mix_ratio_init,
                                 conv.cri = 1e-2,
                                 maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_dsgmm_curve(SP_ECM_DSG_res,
                 x,
                 y,
                 mix_ratio_init,
                 mu_init,
                 sigma_init,
                 alpha_init,
                 eta_init)

#Showing the result of spect_em_dsgmm()
print(cbind(c(mu_init),
            c(sigma_init),
            c(alpha_init),
            c(eta_init),
            c(mix_ratio_init)))

print(cbind(SP_ECM_DSG_res$mu,
            SP_ECM_DSG_res$sigma,
            SP_ECM_DSG_res$alpha,
            SP_ECM_DSG_res$eta,
            SP_ECM_DSG_res$mix_ratio))

print(cbind(true_mu,
            true_sigma,
            true_alpha,
            true_eta,
            true_mix_ratio))

Spectrum adapted EM algorithm by GMM

Description

Perform a peak fitting based on the spectrum adapted EM algorithm by Gaussian mixture model.

Usage

spect_em_gmm(x, y, mu, sigma, mix_ratio, conv.cri, maxit)

Arguments

x

measurement steps

y

intensity

mu

mean of the components

sigma

standard deviation of the components

mix_ratio

mixture ratio of the components

conv.cri

criterion of the convergence

maxit

maximum number of the iteration

Details

Peak fitting is conducted by spectrum adapted EM algorithm.

Value

mu

estimated mean of the components

sigma

estimated standard deviation of the components

mix_ratio

estimated mixture ratio of the components

it

number of the iteration to reach the convergence

LL

variation of the weighted log likelihood values

MU

variation of mu

SIGMA

variation of sigma

MIX_RATIO

variation of mix_ratio

W_K

decomposed component of the spectral data

convergence

message for the convergence in the calculation

cal_time

calculation time to complete the peak fitting. Unit is seconds

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Examples

#generating the synthetic spectral data based on three component Gausian mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(35, 50, 65)
true_sigma      <- c(3, 3, 3)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

y <- c(true_mix_ratio[1] * dnorm(x = x, mean = true_mu[1], sd = true_sigma[1])*10^degree +
       true_mix_ratio[2] * dnorm(x = x, mean = true_mu[2], sd = true_sigma[2])*10^degree +
       true_mix_ratio[3] * dnorm(x = x, mean = true_mu[3], sd = true_sigma[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3

mix_ratio_init  <- c(0.2, 0.4, 0.4)
mu_init         <- c(20, 40, 70)
sigma_init      <- c(2, 5, 4)

#Coducting calculation
SP_EM_G_res <- spect_em_gmm(x, y, mu = mu_init, sigma = sigma_init, mix_ratio = mix_ratio_init,
                            conv.cri = 1e-2, maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_gmm_curve(SP_EM_G_res, x, y, mix_ratio_init, mu_init, sigma_init)

#Showing the result of spect_em_gmm()
print(cbind(c(mu_init), c(sigma_init), c(mix_ratio_init)))
print(cbind(SP_EM_G_res$mu, SP_EM_G_res$sigma, SP_EM_G_res$mix_ratio))
print(cbind(true_mu, true_sigma, true_mix_ratio))

Spectrum adapted ECM algorithm by LMM

Description

Perform a peak fitting based on the spectrum adapted ECM algorithm by Lorentz mixture model.

Usage

spect_em_lmm(x, y, mu, gam, mix_ratio, conv.cri, maxit)

Arguments

x

measurement steps

y

intensity

mu

mean of the components

gam

scale parameter of the components

mix_ratio

mixture ratio of the components

conv.cri

criterion of the convergence

maxit

maximum number of the iteration

Details

Peak fitting is conducted by spectrum adapted ECM algorithm.

Value

mu

estimated mean of the components

gam

estimated scale parameter of the components

mix_ratio

estimated mixture ratio of the components

it

number of the iteration to reach the convergence

LL

variation of the weighted log likelihood values

MU

variation of mu

GAM

variation of gam

MIX_RATIO

variation of mix_ratio

W_K

decomposed component of the spectral data

convergence

message for the convergence in the calculation

cal_time

calculation time to complete the peak fitting. Unit is seconds

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Examples

#generating the synthetic spectral data based on three component Lorentz mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(35, 50, 65)
true_gam        <- c(3, 3, 3)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

#Normalized Lorentz distribution
dCauchy <- function(x, mu, gam) {
    (dcauchy(x, mu, gam)) / sum(dcauchy(x, mu, gam))
  }

y <- c(true_mix_ratio[1] * dCauchy(x = x, mu = true_mu[1], gam = true_gam[1])*10^degree +
       true_mix_ratio[2] * dCauchy(x = x, mu = true_mu[2], gam = true_gam[2])*10^degree +
       true_mix_ratio[3] * dCauchy(x = x, mu = true_mu[3], gam = true_gam[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3

mix_ratio_init  <- c(0.2, 0.4, 0.4)
mu_init         <- c(20, 40, 70)
gam_init        <- c(2, 5, 4)

#Coducting calculation
SP_ECM_L_res <- spect_em_lmm(x, y, mu = mu_init, gam = gam_init, mix_ratio = mix_ratio_init,
                             conv.cri = 1e-2, maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_lmm_curve(SP_ECM_L_res, x, y, mix_ratio_init, mu_init, gam_init)

#Showing the result of spect_em_lmm()
print(cbind(c(mu_init), c(gam_init), c(mix_ratio_init)))
print(cbind(SP_ECM_L_res$mu, SP_ECM_L_res$gam, SP_ECM_L_res$mix_ratio))
print(cbind(true_mu, true_gam, true_mix_ratio))

Spectrum adapted ECM algorithm by PVMM

Description

Perform a peak fitting based on the spectrum adapted ECM algorithm by Pseudo-Voigt mixture model.

Usage

spect_em_pvmm(x, y, mu, sigma, eta, mix_ratio, conv.cri, maxit)

Arguments

x

measurement steps

y

intensity

mu

mean of the components

sigma

standard deviation of the components

eta

mixing ratio of Gauss and Lorentz distribution

mix_ratio

mixture ratio of the components

conv.cri

criterion of the convergence

maxit

maximum number of the iteration

Details

Peak fitting is conducted by spectrum adapted ECM algorithm.

Value

mu

estimated mean of the components

sigma

estimated standard deviation of the components

eta

estimated mixing ratio of Gauss and Lorentz distribution

mix_ratio

estimated mixture ratio of the components

it

number of the iteration to reach the convergence

LL

variation of the weighted log likelihood values

MU

variation of mu

SIGMA

variation of sigma

ETA

variation of beta

MIX_RATIO

variation of mix_ratio

W_K

decomposed component of the spectral data

convergence

message for the convergence in the calculation

cal_time

calculation time to complete the peak fitting. Unit is seconds

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Examples

#generating the synthetic spectral data based on three component Pseudo-Voigt mixture model.
x               <- seq(0, 100, by = 0.5)
true_mu         <- c(35, 50, 65)
true_sigma      <- c(3, 3, 3)
true_eta        <- c(0.3, 0.8, 0.5)
true_mix_ratio  <- rep(1/3, 3)
degree          <- 4

#Normalized Pseudo-Voigt distribution
  truncated_pv <- function(x, mu, sigma, eta) {
    (eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma)) /
      sum(eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma))
  }

y <- c(true_mix_ratio[1]*truncated_pv(x = x,
                                      mu = true_mu[1],
                                      sigma = true_sigma[1],
                                      eta = true_eta[1])*10^degree +
       true_mix_ratio[2]*truncated_pv(x = x,
                                      mu = true_mu[2],
                                      sigma = true_sigma[2],
                                      eta = true_eta[2])*10^degree +
       true_mix_ratio[3]*truncated_pv(x = x,
                                      mu = true_mu[3],
                                      sigma = true_sigma[3],
                                      eta = true_eta[3])*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
K <- 3

mix_ratio_init  <- c(0.2, 0.4, 0.4)
mu_init         <- c(20, 40, 70)
sigma_init      <- c(2, 5, 4)
eta_init        <- c(0.5, 0.4, 0.3)

#Coducting calculation
SP_ECM_PV_res <- spect_em_pvmm(x = x,
                               y = y,
                               mu = mu_init,
                               sigma = sigma_init,
                               eta = eta_init,
                               mix_ratio = mix_ratio_init,
                               conv.cri = 1e-2,
                               maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_pvmm_curve(SP_ECM_PV_res, x, y, mix_ratio_init, mu_init, sigma_init, eta_init)

#Showing the result of spect_em_pvmm()
print(cbind(c(mu_init), c(sigma_init), c(eta_init), c(mix_ratio_init)))
print(cbind(SP_ECM_PV_res$mu, SP_ECM_PV_res$sigma, SP_ECM_PV_res$eta, SP_ECM_PV_res$mix_ratio))
print(cbind(true_mu, true_sigma, true_eta, true_mix_ratio))

Spectrum adapted ECM algorithm by PVMM with a linear background

Description

Perform a peak fitting based on the spectrum adapted ECM algorithm by pseudo-Voigt mixture model with a linear background.

Usage

spect_em_pvmm_lback(x, y, mu, sigma, eta, mix_ratio, x_lower, x_upper, conv.cri, maxit)

Arguments

x

measurement steps

y

intensity

mu

mean of the components

sigma

standard deviation of the components

eta

mixing ratio of Gauss and Lorentz distribution

mix_ratio

mixture ratio of the components

x_lower

lower limit of the measurement steps. Default is a minimum of x

x_upper

upper limit of the measurement steps. Default is a maximum of x

conv.cri

criterion of the convergence

maxit

maximum number of the iteration

Details

Peak fitting is conducted by spectrum adapted ECM algorithm.

Value

mu

estimated mean of the components

sigma

estimated standard deviation of the components

eta

estimated mixing ratio of Gauss and Lorentz distribution

mix_ratio

estimated mixture ratio of the components

it

number of the iteration to reach the convergence

LL

variation of the weighted log likelihood values

MU

variation of mu

SIGMA

variation of sigma

ETA

variation of beta

MIX_RATIO

variation of mix_ratio

W_K

decomposed component of the spectral data

convergence

message for the convergence in the calculation

cal_time

calculation time to complete the peak fitting. Unit is seconds

References

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2019). Spectrum adapted expectation-maximization algorithm for high-throughput peak shift analysis. Science and technology of advanced materials, 20(1), 733-745.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2021). Spectrum adapted expectation-conditional maximization algorithm for extending high–throughput peak separation method in XPS analysis. Science and Technology of Advanced Materials: Methods, 1(1), 45-55.

Matsumura, T., Nagamura, N., Akaho, S., Nagata, K., & Ando, Y. (2023). High-throughput XPS spectrum modeling with autonomous background subtraction for 3 d 5/2 peak mapping of SnS. Science and Technology of Advanced Materials: Methods, 3(1), 2159753.

Examples

#generating the synthetic spectral data based on three component Pseudo-Voigt mixture model.
x              <- seq(0, 100, by = 0.5)
K              <- 3
true_mu        <- c(35, 50, 65)
true_sigma     <- c(3, 3, 3)
true_mix_ratio <- c(0.5/3, 0.5/3, 0.5/3, 0.5)
true_eta       <- c(0.4, 0.6, 0.1)
degree         <- 4

#Normalized Pseudo-Voigt distribution
  truncated_pv <- function(x, mu, sigma, eta) {
    (eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma)) /
      sum(eta*dcauchy(x, mu, sqrt(2*log(2))*sigma) + (1-eta)*dnorm(x, mu, sigma))
  }

y <- c(true_mix_ratio[1]*truncated_pv(x = x,
                                      mu = true_mu[1],
                                      sigma = true_sigma[1],
                                      eta = true_eta[1])*10^degree +
       true_mix_ratio[2]*truncated_pv(x = x,
                                      mu = true_mu[2],
                                      sigma = true_sigma[2],
                                      eta = true_eta[2])*10^degree +
       true_mix_ratio[3]*truncated_pv(x = x,
                                      mu = true_mu[3],
                                      sigma = true_sigma[3],
                                      eta = true_eta[3])*10^degree +
       true_mix_ratio[4]*(c(500*x + 15000) / sum(500*x + 15000))*10^degree)

plot(y~x, main = "genrated synthetic spectral data")

#Peak fitting by EMpeaksR
#Initial values
mu_init        <- c(30, 40, 60)
sigma_init     <- c(4, 4, 4)
mix_ratio_init <- rep(1/(length(mu_init)+3), length(mu_init)+3)
eta_init       <- c(1, 1, 1)

#Coducting calculation
SP_ECM_PV_LBACK_res <- spect_em_pvmm_lback(x = x,
                                           y = y,
                                           mu = mu_init,
                                           sigma = sigma_init,
                                           eta = eta_init,
                                           mix_ratio = mix_ratio_init,
                                           x_lower = min(x),
                                           x_upper = max(x),
                                           conv.cri = 1e-2,
                                           maxit = 2000)

#Plot fitting curve and trace plot of parameters
show_pvmm_lback_curve(spect_em_pvmm_lback_res = SP_ECM_PV_LBACK_res,
                      x = x,
                      y = y,
                      mix_ratio_init = mix_ratio_init,
                      mu_init = mu_init,
                      sigma_init = sigma_init,
                      eta_init = eta_init,
                      x_lower = min(x),
                      x_upper = max(x))

#Showing the result of spect_em_pvmm_lback()
print(cbind(SP_ECM_PV_LBACK_res$mu, SP_ECM_PV_LBACK_res$sigma, SP_ECM_PV_LBACK_res$eta,
            SP_ECM_PV_LBACK_res$mix_ratio[1:K]))

print(cbind(true_mu, true_sigma, true_eta, true_mix_ratio[1:K]))