LD score regression

```
snp_ldsc(
ld_score,
ld_size,
chi2,
sample_size,
blocks = 200,
intercept = NULL,
chi2_thr1 = 30,
chi2_thr2 = Inf,
ncores = 1
)
snp_ldsc2(
corr,
df_beta,
blocks = NULL,
intercept = 1,
ncores = 1,
ind.beta = cols_along(corr),
chi2_thr1 = 30,
chi2_thr2 = Inf
)
```

- ld_score
Vector of LD scores.

- ld_size
Number of variants used to compute

`ld_score`

.- chi2
Vector of chi-squared statistics.

- sample_size
Sample size of GWAS corresponding to chi-squared statistics. Possibly a vector, or just a single value.

- blocks
Either a single number specifying the number of blocks, or a vector of integers specifying the block number of each

`chi2`

value. Default is`200`

for`snp_ldsc()`

, dividing into 200 blocks of approximately equal size.`NULL`

can also be used to skip estimating standard errors, which is the default for`snp_ldsc2()`

.- intercept
You can constrain the intercept to some value (e.g. 1). Default is

`NULL`

in`snp_ldsc()`

(the intercept is estimated) and is`1`

in`snp_ldsc2()`

(the intercept is fixed to 1). This is equivalent to parameter`--intercept-h2`

.- chi2_thr1
Threshold on

`chi2`

in step 1. Default is`30`

. This is equivalent to parameter`--two-step`

.- chi2_thr2
Threshold on

`chi2`

in step 2. Default is`Inf`

(none).- ncores
Number of cores used. Default doesn't use parallelism. You may use

`bigstatsr::nb_cores()`

.- corr
Sparse correlation matrix. Can also be an SFBM.

- df_beta
A data frame with 3 columns:

`$beta`

: effect size estimates`$beta_se`

: standard errors of effect size estimates`$n_eff`

: either GWAS sample size(s) when estimating`beta`

for a continuous trait, or in the case of a binary trait, this is`4 / (1 / n_control + 1 / n_case)`

; in the case of a meta-analysis, you should sum the effective sample sizes of each study instead of using the total numbers of cases and controls, see doi:10.1016/j.biopsych.2022.05.029 ; when using a mixed model, the effective sample size needs to be adjusted as well, see doi:10.1016/j.xhgg.2022.100136 .

- ind.beta
Indices in

`corr`

corresponding to`df_beta`

. Default is all.

Vector of 4 values (or only the first 2 if `blocks = NULL`

):

`[["int"]]`

: LDSC regression intercept,`[["int_se"]]`

: SE of this intercept,`[["h2"]]`

: LDSC regression estimate of (SNP) heritability (also see coef_to_liab),`[["h2_se"]]`

: SE of this heritability estimate.

```
bigsnp <- snp_attachExtdata()
G <- bigsnp$genotypes
y <- bigsnp$fam$affection - 1
corr <- snp_cor(G, ind.col = 1:1000)
gwas <- big_univLogReg(G, y, ind.col = 1:1000)
df_beta <- data.frame(beta = gwas$estim, beta_se = gwas$std.err,
n_eff = 4 / (1 / sum(y == 0) + 1 / sum(y == 1)))
snp_ldsc2(corr, df_beta)
#> int h2
#> 1.0000000 0.2335429
snp_ldsc2(corr, df_beta, blocks = 20, intercept = NULL)
#> int int_se h2 h2_se
#> 0.4986445 0.2526338 0.6195226 0.1818980
```