Learn R Programming

MixSemiRob (version 1.1.0)

semimrGen: Semiparametric Mixture Data Generator

Description

`semimrGen' is used to generate data for a two-component semiparametric mixture of regression models: $$p m_1(x) + (1-p) m_2(x),$$ where \(m_1(x) = 4 -\sin(2\pi x)\) and \(m_2(x) = 1.5 + \cos(3\pi x).\) This function is used in the examples for the semimrLocal and semimrGlobal functions. See the examples for details.

Usage

semimrGen(n, p = 0.5, var = c(.1, .1), u)

Value

A list containing the following elements:

x

vector of length n, which represents the explanatory variable that is randomly generated from Uniform(0,1).

y

vector of length n, which represent the response variable that is generated based on the mean functions \(m_1(x)\) and \(m_2(x)\), with the addition of normal errors having a mean of 0 and a standard deviation specified by the user.

true_mu

n by 2 matrix containing the values of \(m_1(x)\) and \(m_2(x)\) at x.

true_mu_u

length(u) by 2 matrix containing the values of \(m_1(x)\) and \(m_2(x)\) at u.

Arguments

n

a scalar, specifying the number of observations in \(x\).

p

a scalar, specifying the probability of an observation belonging to the first component, i.e., \(p\) in the model.

var

a vector of variances of observations for the two components.

u

a vector of grid points for \(x\). If some specific explanatory variable are needed, create a vector and assign to u.

See Also

semimrLocal, semimrGlobal, semimrBinFull

Examples

Run this code
n = 100
u = seq(from = 0, to = 1, length = 100)
true_p = c(0.3, 0.7)
true_var = c(0.09, 0.16)
out = semimrGen(n = n, p = true_p[1], var = true_var, u = u)

Run the code above in your browser using DataLab