FAQ and Troubleshooting
FAQ, troubleshooting, np, npRmpi, crs, install, factor, MPI
Use this page for practical answers and routes to the current package guidance.
For more detailed guidance, see:
Fast routes
| If you need… | Start here |
|---|---|
| the smallest runnable scripts | Quickstarts |
| density, conditional-density, distribution, or quantile examples | Density, Distribution, Quantiles |
| classification or conditional-mode examples | Classification and Modes |
| plotting, predictions, or interval examples | Plotting and Intervals |
npRmpi install and launch guidance |
MPI and Large Data |
| factors, ordered variables, and formula traps | Data Preparation and Variable Types |
| runtime, memory, and scaling advice | Runtime, Memory, and Scaling |
| function-name lookup | Reference and Function Lookup |
Which package should I start with?
Start with np unless you already know that you need MPI or spline methods.
- Use
npfor core kernel regression, density, distribution, and testing on one machine. - Use
npRmpiwhen the same workflow becomes large or slow enough that MPI is warranted. - Use
crswhen regression splines or spline-specific constraints are the natural tool.
The short chooser lives on Choose a Package.
I am new to R. Where should I begin?
Begin with Install and Get Started. Then run one small example from Quickstarts before worrying about the longer scripts.
Good general resources are:
How do I keep my installed packages current?
This remains a sensible command:
## Refresh installed packages when you want a conservative update sweep
update.packages(checkBuilt = TRUE, ask = FALSE)What should I check when moving to 0.80-2?
If you are updating from 0.80-1, the principal user-facing changes in np and npRmpi are concentrated in plotting and stricter input validation:
- use snake_case for compound plot arguments, including
data_overlay,data_rug,factor_boxplot,boxplot_outliers,coef_index,common_scale,proper_method,proper_control,bias_control,boot_control,grid_control,render_control,gaussian_draws,random_seed, andgradient_order; the former dotted plot spellings fail with migration guidance, - keep established estimator spellings such as
gradient.order,se.type, andrandom.seed; the snake_case change is plot-facing rather than a package-wide renaming exercise, - replace
output = "both"withoutput = "plot-data"; bothoutput = "data"andoutput = "plot-data"return annp_plot_dataobject whose interval columns are absolute endpoints, - supply numeric integer/double responses to
npreg(),npplreg(),npscoef(), andnpindex()and their selectors; factors and ordered responses now fail rather than being interpreted through internal codes, - treat the two values in
np_grid_control(xtrim = c(a, b))as the lower and upper quantile endpoints of the displayed range; single-index plots apply that range to the fitted index and reject slice-holdingxq, - a named formula is now accepted in
npsigtest(bws = y ~ x, ...), and density selectors honor explicittransform.boundsthrough formula and native adapters, - corrected bounded-density intervals cover more fixed-bound Gaussian, beta, uniform, and Epanechnikov routes, but all bias-corrected intervals remain experimental pre-beta research and are not recommended for general-purpose inference,
- RNG replay and MPI worker adoption are checked more strictly; unsupported hidden generator state or mismatched package R/native identities fail clearly rather than being silently remapped or combined.
## Compute a plot payload without drawing, then inspect and replay it
plot_data <- plot(fit, errors = "asymptotic", output = "data")
curve_data <- as.data.frame(plot_data)
plot(plot_data)For several panels, targets, or bands, select the desired component explicitly with as.data.frame(plot_data, panel = ..., target = ..., band = ...). Replay uses the retained geometry and does not refit, resample, or consume random numbers. Calls written for releases older than 0.80-1 may require additional migration; use the package NEWS.md files as the canonical historical record.
Why can an external evaluation row return NA?
If every computed explanatory-kernel weight is zero, or a required normalization is non-finite, the affected regression, conditional, quantile/mode, single-index, smooth-coefficient, and hat routes return NA for the external row and issue one consolidated notice. Defined rows in the same call remain available.
This most often means that a compact-support evaluation point lies too far from the training support for the selected bandwidth. Check the evaluation grid and the fitted bandwidth object before deciding whether a larger bandwidth or a different supported kernel is scientifically appropriate. The package does not invent a numerical floor or a fabricated estimate for that row.
Where is the gentlest introduction to the packages?
Use the package vignettes and then the gallery pages.
## Start with the installed package vignettes
vignette("np_getting_started", package = "np")
vignette("np_entropy_tests", package = "np")
vignette("crs_getting_started", package = "crs")
vignette("npRmpi_getting_started", package = "npRmpi")For a shorter web route, start with:
How do I find functions, examples, and demos quickly?
For package help:
## Use help lookups and runnable examples directly from the installed packages
library(help = "np")
library(help = "crs")
?npreg
?crsFor runnable examples:
## Run the built-in examples and demos from the installed packages
example(npreg)
example(crs)
demo(package = "crs")For worked examples and topic guides:
Where do I find runnable examples?
- For
np, start with Quickstarts, then move to Density, Distribution, Quantiles or Worked Examples depending on the task. - For
npRmpi, start with Quickstarts and then MPI and Large Data. - For
crs, usedemo(package = "crs")and the scripts on Splines. - For interactive teaching examples, use Interactive Demos.
How should I prepare mixed data?
The class of each variable matters. Continuous variables can remain numeric, but unordered categorical variables should be factors and ordered categorical variables should be ordered factors when that distinction is meaningful.
## Build a mixed-data frame with explicit variable classes
mydat <- data.frame(y = rnorm(200),
x_cont = runif(200),
x_unordered = factor(sample(c("a", "b", "c"), 200, replace = TRUE)),
x_ordered = ordered(sample(1:4, 200, replace = TRUE)))This is not just bookkeeping. In np, the variable class affects the weighting rule used by the estimator.
For a more deliberate checklist, see Data Preparation and Variable Types.
Does formula syntax imply a linear-additive model?
No. In np, a formula such as
## Formula syntax identifies the response and covariates
y ~ x1 + x2 + x3identifies the response and covariates. It does not impose an ordinary linear-additive model or other parametric structure.
Why should I create an explicit bandwidth object?
Because in np the bandwidth object is often the key object in the workflow.
## Create the bandwidth object explicitly before fitting
bw <- npregbw(y ~ x1 + x2, data = mydat)
summary(bw)
fit <- npreg(bws = bw)Working explicitly this way makes it easier to inspect the chosen bandwidths, reuse them, and avoid unnecessary recomputation.
If you instead begin with a single high-level estimator call, the fitted object retains its selected bandwidth object. Reuse that $bws component when you later want another option without repeating the search:
## Search and fit first; later request gradients without searching again
fit <- npreg(y ~ x1 + x2, data = mydat)
fit_grad <- npreg(bws = fit$bws, gradients = TRUE)This reruns only the fitting work needed for the new request, not bandwidth optimization.
For the broader runtime side of this issue, see Runtime, Memory, and Scaling.
Where do I find the changelog?
Use the package page on CRAN and the package repository NEWS.md or release notes as the canonical release history.
Some older examples use attach(). Should I?
Older scripts and vignettes sometimes use attach() because that was a common style at the time. For modern work, it is usually better to avoid attach() and instead use:
- explicit
data =arguments, - explicit data-frame references such as
mydat$x, - or a short preprocessing step that creates a clean data frame.
That keeps variable scope clearer and reduces accidental name collisions.
Why can bandwidth selection take a while?
Because many of these methods are doing real search and resampling work rather than evaluating a closed-form formula once.
Practical advice:
- start with a small example,
- confirm the workflow in serial first,
- move to
npRmpionly when the serial workflow is the right one but too slow for the job at hand.
The fuller version of that advice now lives on Runtime, Memory, and Scaling.
I have data from Stata, SAS, SPSS, or elsewhere. Can I still use these packages?
Yes. The important point is not the original file format but the data frame you hand to the modeling function once the data are in R. After import, make sure the variable classes are correct before fitting models, especially for factors and ordered factors.
How do I cite the packages?
Use citation() from inside R and see Books, Papers, and Citation for the package papers and books.
## Ask the installed packages for their current citation records
citation("np")
citation("npRmpi")
citation("crs")I am using npRmpi and see npRmpi auto-dispatch requires an active MPI slave pool
That means there is no active MPI session.
- For interactive work, call
npRmpi.init(nslaves = 1)first. - For
mpiexecjobs, initialize withnpRmpi.init(mode = "attach", ...)near the top of the script.
On current package sources, Windows belongs in the second branch rather than the first.
The detailed route is on MPI and Large Data.
I am using npRmpi and see could not find function "mpi.bcast.cmd"
This usually means a manual-broadcast/profile script started without the required profile startup.
Check the following:
R_PROFILE_USERpoints to the intended profile file,R_PROFILEis cleared,- the command is not using
R CMD BATCH --vanilla, - the effective launch command really includes
-env R_PROFILE_USER <path>.
I need examples for npRmpi on larger or more complex systems
Use MPI and Large Data. That page now treats:
session/spawnas the default instructional path,attachas the normalmpiexecautodispatch route,profile/ manual-broadcast as the advanced route, and often the right one for heterogeneous clusters.
Where should I look next?
Can crs recover something as simple as linear regression?
Yes. Spline methods include simpler structures as special cases when the basis is restricted appropriately. A short illustration now appears on Splines.
I am using crs and the search is slow or memory hungry
That usually indicates a large search space rather than an estimator failure.
The first levers to inspect are:
cv.df.mindegree.maxsegments.maxbasiscomplexity
The practical route now lives on Spline Search and Tuning, with the broader ecosystem version on Runtime, Memory, and Scaling.
I want a smoother spline, fixed degree, or the selected knots
Address those practical questions directly rather than altering the interpretation of the cross-validated result.
See Spline Search and Tuning for:
- imposing a minimum spline degree,
- holding degree fixed and searching over knots,
- retrieving knot locations from the fitted model,
- and the linear-regression special case.
Older FAQ PDFs
The final archived np and crs FAQ PDFs remain available under Older Documents and Current Guides. Treat them as historical references; use this FAQ and the current package manuals for current interfaces.