Cook the pasta according to the package directions, reserving ½ cup of the cooking water; drain the pasta and return it to the pot.
Meanwhile, heat oven to 350° F. Spread the walnuts on a rimmed baking sheet and toast, tossing once, until golden, 6 to 8 minutes. Let cool, then coarsely chop.
Combine the raisins and vinegar in a small bowl.
Heat the oil in a large skillet over medium heat. Add the garlic and anchovies and cook, stirring and breaking up the anchovies, until fragrant, 2 to 3 minutes. Add the walnuts and toss to combine.
Add the anchovy mixture, raisins mixture, pecorino, parsley, ¼ teaspoon each salt and pepper, and ¼ cup of the cooking water to the pasta and toss to coat (add more cooking water as needed to moisten the pasta). Sprinkle with the shaved pecorino.