Main arguments of dp_pca()
| Argument | Description |
|---|---|
X |
Input data matrix or data frame with at least two numeric variables. Non-numeric columns are excluded from the PCA features. |
privacy |
Privacy settings from privacy_control(),
allocated to loading, scree, and score estimation. |
scree |
Required list specifying k,
method, control, and optionally
mono. Defaults within the list are k = NULL
(all components), method = "clipped", and
mono = TRUE; a method-specific control is
required. |
score |
List specifying the private histogram
method ("sparse" or "add") and
bins. Defaults: method = "sparse",
bins = c(20, 20). |
axes |
Two distinct PC indices used for the score plot and
biplot. Default: c(1, 2). |
group |
Optional grouping column name or vector of group
labels. The grouping column is excluded from PCA features. Default:
NULL. |
non_private |
Whether to compute and store an ordinary PCA reference
for comparison. If TRUE, plot() automatically
displays both ordinary and DP results; if FALSE, only DP
results are shown. Default: FALSE. |
V_dp |
Optional previously estimated full private PC direction
matrix. When supplied, loading estimation is skipped. Default:
NULL. |
cpp.option |
Whether to use the compiled implementation when
estimating private PC directions internally. Default:
TRUE. |
For detailed explanations of the scree and
score options, including available estimation methods and
their tuning parameters, see the DP
Scree Plot Tutorial and DP
Score Plot Tutorial, respectively.
The V_dp argument allows previously estimated private PC
directions to be reused in dp_score(). For a detailed
example, see Reusing
Private PC Directions in the DP Scree Plot tutorial.
Estimate four scree components and use PC1 and PC2 for the score grid:
set.seed(123)
pca_fit <- dp_pca(
X,
privacy = privacy,
scree = list(
k = 4,
method = "clipped",
control = clipped_control(C_clip = 3)
),
score = list(method = "sparse", bins = c(9, 9)),
axes = c(1, 2),
group = "Class"
)
#> Warning: PCA: 10 numeric variables used.
#> Excluded from PCA (4): Split, Speaker, Sex, Class.
#> Grouping variable: Class
#> Groups (11): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
pca_fit
#> Differentially Private PCA
#> Data: 990 observations x 10 variables
#> Components: 10 PC directions; 4 scree estimates
#> Score axes: PC1, PC2
#> Group variable: Class
#> Groups: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
#> Methods: scree = clipped ; score = sparse
#> Total privacy budget: eps = 10 ; delta = 1e-04
#> Non-private reference: not storedThe fit reports that ten numeric variables are used, that
Split, Speaker, Sex, and
Class are excluded from PCA, and that the grouping variable
is Class. It also lists the 11 observed vowel groups.