Comparing weights in SPSS regression and R lm In SPSS, you can use a variable as WLS Weight when carrying regression.
In R, you can use a variable as an argument weight in lm().
I was wondering if they are the same thing or if there is any difference between them? I think there is none, but can not find anything on this topic.
If there is a difference, how should I proceed with R to do the same as an WLS Weight regression in SPSS?
Thank you!

UPDATE
My questions is specific to standardized beta. Overall both approaches lead to the same results, but not the standardized beta.
jd <- data.frame(x = 1:10,
                 w = 1/x,
                 y = x^2)
res <- lm(y ~ x, weights = w, data = jd)
summary(res)

Call:
lm(formula = y ~ x, data = jd, weights = w)

Weighted Residuals:
   Min     1Q Median     3Q    Max 
-4.159 -3.276 -1.193  2.516  5.993 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) -13.5039     3.7870  -3.566  0.00734 ** 
x             9.4553     0.8739  10.819  4.7e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.991 on 8 degrees of freedom
Multiple R-squared:  0.936, Adjusted R-squared:  0.928 
F-statistic: 117.1 on 1 and 8 DF,  p-value: 4.701e-06

QuantPsyc::lm.beta(res)
        x (weights) 
0.8377007 0.0767146 

And here is the SPSS output for the same toy data set.

Estimates and standard error are the same, but the standardized beta is not (using QuantPsyc::lm.beta() function).
It this a bug or is it intended? If so, why does this occur?
 A: SPSS Statistics supports two basic kinds of weights: simple case weighting usable by almost any of the statistical procedures and complex sampling weights for nonrandom surveys.  The latter are applicable to the complex sampling procedures, but a sample design specification is also required.
Some procedures such as WLS have special weighting schemes built in that you would specify in their commands.  The CTABLES procedure also supports effective base weighting.
The statistical formulas for all these are documented in the Algorithms manual, which is available via Help > Documentation in PDF format.
A: I found out SPSS uses weighted means and weighted standard deviations to standardize data whereas the QuantPsyc::lm.beta() function does not.
jd <- data.frame(x <- 1:10,
                 w = 1/x,
                 y = x^2)

res <- lm(y ~ x, weights = w, data = jd)

# Compute weighted SD like SPSS
sd.wt <- function(x, w){
  sqrt(sum(w * (x - weighted.mean(x, w))^2) / (length(x) -1))
}

my.lm.beta <- function(MOD){
  b <- coef(MOD)[-1]
  w <- as.double(MOD$model$`(weights)`)
  D <- MOD$model[-which(names(MOD$model) == "(weights)")]
  s <- sapply(D, sd.wt, w = w)
  b * s[-1] /  s[1]
}

QuantPsyc::lm.beta(res)
       x1 (weights) 
0.8377007 0.0767146 
my.lm.beta(res)
       x1 
0.9674867 

SPSS uses a different method than R for weighted covariances though. SPSS uses $$s_x = \sqrt{\frac{\sum w_i (x- \bar{x^*})^2}{n-1}}$$ whereas R computes $$s_x = \frac{\sum \sqrt{t_i}(x_i-\bar{x^*})^2}{1-\sum t_i^2}$$ where $$t = \frac{w}{\sum w}$$ via cov.wt().

To get the confidence intervals.
# Compute weighted SD like SPSS
sd.wt <- function(x, w){
  sqrt(sum(w * (x - weighted.mean(x, w))^2) / (length(x) -1))
}

# Updated my.lm.beta for non-weighted lm
my.lm.beta <- function(MOD){
  b <- coef(MOD)[-1]
  wei <- MOD$model$`(weights)`
  if(is.null(wei)){
    s <- sapply(MOD$model, sd)
  }else{
    w <- as.double(wei)
    D <- MOD$model[-which(names(MOD$model) == "(weights)")]
    s <- sapply(D, sd.wt, w = w)
  }
  b * s[-1] /  s[1]
}

# CI
my.lm.ci <- function(MOD, alpha = .05){
  OUT <- data.frame(b = my.lm.beta(MOD))
  SE <- sqrt(diag(vcov(MOD)))[-1] * OUT$b / coef(MOD)[-1]
  OUT$CI.inf <- OUT$b + qnorm(alpha/2) * SE
  OUT$CI.sup <- OUT$b + qnorm((1-alpha/2)) * SE
  OUT
}

# Test
my.lm.ci(res)

